Cohort sync timeout - solutions?

Cohort sync timeout - solutions?

by Charles Roper -
Number of replies: 0

Hi,

We have a cohort containing 400+ users. When we add a cohort sync enrolment type to a course using this cohort, Moodle sits there processing for several minutes (5+ mins). This results in a timeout. The process appears to carry on in the background and does eventually complete, but the experience for the admin sees an alarming and confusing variety of error messages and the assumption is that something is broken.

I have increased the PHP timeout to 10 minutes to account for this, but we still get a 524 timeout from Cloudflare, which is set to 100 seconds and cannot be changed unless one has an enterprise account (we only have a Pro account).

In the link above, Cloudflare have this to say:

4. If you need to have scripts that run for longer than around 100 seconds without returning any data to the browser, you can’t run these through Cloudflare. There are a couple of options: Run the scripts via a grey-clouded subdomain or change the script so that it kicks off a long-running background process and quickly returns a status which the browser can poll until the background process has completed, at which point the full response can be returned. This is the way most people do this type of action as keeping HTTP connections open for a long time is unreliable and can be very taxing also.

So I wonder if anyone else has a solution for this without resorting to running on a "grey-cloud" subdomain (this is a Cloudflare term for routing past their services)?

I note there is a feature enhancement in the bug tracker regarding this problem: https://tracker.moodle.org/browse/MDL-68534

Is there perhaps a CLI command or plugin that can do the job? I've already looked at Moodle's built-in CLI commands and browsed Moosh's commands, but can't see anything regarding cohort sync. Have I missed anything?

Is there perhaps another way we could kick off a cohort sync without going through the UI? I.e., via CLI or a custom PHP script we can fire using an async AJAX request?

Many thanks!

Charles

Average of ratings: -