Troubleshooting Moodle ad hoc task backlogs

When Moodle notifications, course copies or backups stop moving, this page explains how to read the ad hoc task queue, handle fail delays and find the plugin blocking it.

On this page

Why Moodle ad hoc task backlogs stall and when to troubleshoot them

When course copies, backups or notifications sit waiting and users start asking why nothing happens, the likely cause is Moodle's ad hoc task queue backing up. An ad hoc task is a one-off unit of background work that Moodle queues to run later, such as sending a notification, copying a course or building a backup. Cron picks these tasks up and runs them. This page explains how to read the queue and logs, find the task or plugin that is blocking it, and clear the backlog safely. Clearing a queue is an operations task on infrastructure your team controls, so it belongs in a change-managed runbook rather than in an ad hoc fix during a busy morning.

Teams usually need this work in three situations: after a change to cron, such as moving to a system scheduler or altering the PHP user that runs it; after installing or upgrading a plugin that registers its own background tasks; and during peaks of course activity, when many backups or copies are requested at once and the runners cannot keep pace. Each situation leaves a different trail in the queue, so the first step is to confirm which one applies. Check whether cron is running at the frequency your site expects, whether the backlog started at a known change time, and whether one task type dominates the queue.

Before you start, confirm three things with your own environment rather than assuming them. Confirm the Moodle version you run, because the queue display and failure handling differ between releases, and the ad hoc task fail delay can be inspected and reset only on versions that provide that feature. Confirm who on your team can access the site administration reports and the server logs, and who can make a change in the production window. Confirm where your web server and cron logs are stored and how long they are kept. Without those answers, a backlog investigation tends to stall in the same way the queue has.

How to read the ad hoc task queue and logs step by step

This sequence takes an administrator from a stalled notification, course copy or backup to a documented picture of which task is blocking the queue and why. The record it produces is what you need before any change is made to the site.

  1. Confirm the backlog is real before touching anything

    Start by checking that the stall is not a display delay or a single user's perception. Ask the person who reported it for the task type, the time they started it and the course or site involved, then confirm the stall in the site administration task views. Record the time of the check, the Moodle version shown in site administration, and whether cron is running. You know this step is done when you can state, in one sentence, which kind of work is waiting and since when.

  2. Open the ad hoc task list in site administration

    In site administration, open the scheduled and ad hoc task views and locate the ad hoc tasks that are queued or running. Note the task class names, the number of queued items for each, and whether any entry is marked as failing. Export or copy the list into your incident record so the state is preserved before retries or resets. The step is complete when you have a dated snapshot showing the queue size and the task classes waiting in it.

  3. Identify the oldest and most repeatedly failing task

    Sort the queue by age and look for the oldest entry, then look for any task class that appears several times with a failure history. A single old task at the head of the queue can hold back everything behind it, while repeated failures of one class point to a plugin or configuration fault. From Moodle 5.0, the fail delay is displayed and can be reset, so read it for each candidate and record it. You know this step is done when you have one named task class and its fail delay written down.

  4. Read the failure message and stack trace in the logs

    Find the failure entries for the suspect task in the server logs and the Moodle error output for the same time window. From Moodle 5.1, failed tasks always log a stack trace, so the frames show which plugin or core file raised the exception. Record the exception class, the first frame that is not core Moodle code, and the message text. The step is done when you can name the file or plugin path responsible for the exception, or you have confirmed the trace stops inside core code.

  5. Correlate the failures with cron timing

    Compare the timestamps of the failed runs with cron execution times from your scheduler or system log. Check whether failures cluster around particular cron runs, long running jobs, backup windows or maintenance tasks, and whether any run overlapped with another. If a second cron process was started during a slow run, record that too. You know this step is done when you have a timeline that shows whether the failures follow cron frequency, workload peaks or a specific change.

  6. Record the evidence before making any change

    Before resetting a fail delay, clearing a task, adding a runner or updating a plugin, write down the snapshot from the queue, the stack trace, the plugin versions, the cron timeline and the site's recent changes. Save copies of the relevant log lines and note who is making the change. This record lets you compare the state after the fix and gives your team a reference if the same class stalls again. The step is complete when the incident record can be read by someone who was not involved.

  7. Confirm the record matches the suspected cause

    Review the evidence with the plugin owner or site administrator and confirm the suspected cause fits the data: the task class, the exception, the timing and the recent changes. If the cause points to a third-party plugin, check its listed Moodle version support before deciding on the next action. Only after this review should you move to remediation. You know this step is done when the team agrees on one cause and one next action, both written in the incident record.

How a stalled task moves from queue to failure to retry

The path starts when cron triggers the task runner, which picks up queued ad hoc tasks such as notifications, course copies or backups. A task either completes or fails, and a failed task waits out its fail delay before the runner tries it again. Check the queue and the task log at the failure point, and look for a long-running task that holds the runner while everything behind it waits.

Ad hoc tasks move from cron-triggered runners to completion, failure with a fail delay, or a blocked queue.

Fail delays, resets and long-running tasks compared

A task that fails and is retried will be pushed back by Moodle's fail delay, so the queue appears slow even though the task is still being attempted. In Moodle 5.0, the fail delay is displayed for each task and can be reset, which makes it visible whether a task is stuck in a retry cycle. In Moodle 5.1, every failed task always logs a stack trace, so the cause is recorded in the logs rather than depending on the administrator to capture it.

  • Read the stack trace first: In Moodle 5.1 or later, the trace in the logs names the function and file that threw the error, which usually points to a plugin, a missing table or a bad setting.
  • Check the fail delay: On Moodle 5.0 or later, confirm how long the task is waiting before its next attempt and how many times it has failed.
  • Look for a shared cause: If several tasks from one component fail together, suspect that component, such as a plugin upgrade or a changed external service.
  • Confirm the external dependency: Notifications and course copies that call mail servers, storage or web services often fail because the remote end changed, not because Moodle did.
  • Reset only after fixing the cause: A reset clears the delay so the task runs again immediately. Doing it before the fault is fixed only produces another failure.

Before resetting, confirm that the failure cause is fixed and that the task is safe to run again, since some tasks are not idempotent.

Which fix fits which backlog cause

This table compares the common responses to a stalled ad hoc task queue, from waiting to escalating to a plugin author. Read each row against the cause you found in the logs, and check the confirmation column before changing anything on a production site. The main takeaway is that resetting the fail delay and disabling a plugin both change what runs next, so they should follow a diagnosis rather than precede it.

OptionWhen it fitsRiskWhat to confirm first
Wait for the task to retryTask failed once from a transient error, such as a remote service being briefly unreachable, and the queue is otherwise movingLow, but the queue stays blocked for as long as the fail delay lastsWhether the failure is recorded as transient in the logs and the task shows a rising fail delay
Reset the fail delayTask has a long fail delay after an error that has already been fixed, such as restored credentials or a restored database connectionMedium, because the task runs immediately and may fail again or repeat side effectsMoodle 5.0 displays the fail delay and allows it to be reset, so confirm your site is on 5.0 or later and the underlying error is resolved
Add another cron runnerMany tasks are waiting, none are failing, and the queue grows faster than one runner clears itMedium, because concurrent runners may compete for the same work and load the databaseCron frequency warnings, runner process count, and whether a single long task is holding the only runner
Disable or fix the blocking pluginStack traces point to one plugin's task class, and the same class fails on every runMedium to high, because disabling may break features that depend on the plugin and fixing may need code changesPlugin version against your Moodle version, the plugin's documented task class name, and whether a vendor fix or update exists
Escalate to the plugin authorFailure lives inside third-party code, you cannot patch it safely, or the plugin is unmaintained for your Moodle versionLow for your site, but resolution time depends on the author or communityPlugin's issue tracker, support channel, and the stack trace copied from the failed task log
Investigate a long-running taskTask runs for a long time without failing, such as a large course copy or backup, and the queue waits behind itLow to medium, because stopping it mid-run can leave partial outputExpected size of the job, the task's start time in the logs, and whether your site has spare runner capacity

When adding runners helps and when it makes things worse

Adding task runners can clear a backlog faster, but only when the bottleneck is runner capacity. When the limit is the database, shared storage or a blocked task, extra runners add contention, duplicate work and noise. Check each card below before you start another cron process.

Confirm runner count is the bottleneck

Adding runners only helps when tasks are waiting for a free process while the database and storage are idle. Compare queue depth, task start times and database load before and after a change. If queued tasks wait on a single slow plugin or a locked table, another runner will simply sit behind the same problem. Confirm the cron and runner guidance for your Moodle version in the release documentation before you change the process count.

Moodle 5.1 notes

Watch database contention

Every runner reads and writes the same queue and course tables, so more runners can increase locking and slow every page on the site. Watch for lock waits, long-running queries and connection pool exhaustion while the backlog is draining. If the database is already near its limit, add capacity or tune the slow query first. Treat a runner increase as a load test, not a permanent setting.

Check shared storage for course backups

Course backup and restore tasks write large archives to moodledata or a shared directory. Several runners working on backups at once can saturate disk I/O, fill the volume or create partial files if the mount is slow. Confirm that every node sees the same storage path, that free space is monitored, and that backup files are not being written by two processes to the same location.

Guard against duplicate processing

Some tasks are not safe to run twice, such as sending notifications or creating course copies. Confirm that your Moodle version locks tasks while they run and that no scheduler starts the same cron command from two hosts. Check the logs for the same task ID appearing in parallel runs. If you see duplicates, stop the extra scheduler before you tune anything else.

Match the PHP user and permissions

Runners started under a different user from the web server can create files that the web process cannot read or update. This shows up as backups that finish but cannot be downloaded, or caches that fail to clear. Run every runner as the same PHP user, confirm ownership of moodledata and temporary directories, and test a backup from the web interface after each change.

Monitor running processes and fail delays

Extra runners are hard to manage without knowing which processes are alive and what they are doing. Track the number of running cron processes, their start times and the fail delay shown for queued tasks. Moodle 5.0 displays the fail delay and allows it to be reset, which helps you tell a slow task from one that keeps failing. Set alerts for processes that run longer than your normal task window.

Setting up a safe recovery and runner change

This sequence makes a queue recovery or runner change reversible and measurable, so the team can show what was changed, what it did to the backlog, and how to undo it if the fix does not hold.

  1. Take a backup or snapshot first

    Before any change, the administrator takes a copy of the database and the moodledata directory, and records the Moodle code version and the cron or runner configuration. For a virtual machine or storage volume, a snapshot is an additional safety net, but it does not replace a logical database backup that has been checked for restore. The step is done when the backup job has finished without errors and someone other than the person running the change has confirmed the backup exists and can be read. Ask your hosting or backup team how long a restore test takes in your environment before you rely on it.

  2. Open a change window and enable maintenance if needed

    Decide whether the change touches running tasks. Restarting runners or clearing a stuck task while users are submitting work can create duplicate or partial results, so a change window with maintenance mode is often the safer choice. The administrator announces the window to the course and platform owners, then enables maintenance mode using the command line tools and confirms the site shows the maintenance page to a test account. Do not kill sessions or purge caches in this step unless the troubleshooting notes call for it.

  3. Record the current queue state

    Capture the ad hoc task queue as it stands: the number of queued tasks, their component and classname, the fail delay and the last error for each failing task, and the timestamp of the oldest waiting task. Also save the relevant lines from the cron and task logs and the output of the runner processes. This record is your baseline, so later you can tell whether the backlog is shrinking or only moving. The step is complete when the snapshot is stored outside the server and the team agrees on which task types are blocked.

  4. Identify one change and write down the reason

    Choose a single intervention based on the evidence: for example, reset the fail delay on one failing task after its cause is fixed, add one runner process, or disable one plugin's task while its error is investigated. Write down the expected effect and the rollback step for that change. Making several changes at once hides which one worked and which one caused a new problem. The step is done when the change, its expected effect and its rollback are written in the change record and approved by the person who owns the affected plugin or service.

  5. Apply the single change

    The administrator makes only the chosen change, using the documented method for the Moodle version in use. Starting an extra runner, for example, should be done under the same PHP user and with the same configuration as the existing runners so that tasks are not picked up under different permissions. Record the exact time and command or setting used. The step is complete when the change is confirmed in the configuration or process list, and the runner or task status shows the new state without errors at startup.

  6. Verify the backlog drains

    Watch the queue against the baseline for a period the team agrees on before the change window starts. Check that the count of waiting tasks falls, that the oldest waiting task moves forward, that the previously failing task either completes or fails with a new, understood error, and that no new failures appear in the logs. If the backlog grows or a new task type starts failing, roll back the change using the recorded step rather than applying a second fix on top. The step is done when the queue has returned to a normal level and the logs show steady progress.

  7. Document the outcome and exit maintenance

    Disable maintenance mode once the queue is stable and users have been able to reach the affected features. Write the outcome in the change record: the baseline, the change made, the time it was applied, the queue state afterwards, any open errors, and the owner for follow-up. Keep the record with the runbook so the next person can see what was tried. The step is complete when the change record is signed off, the maintenance notice is withdrawn, and any plugin or root cause still under investigation has a ticket with an owner.

Security and operational risks while clearing the queue

Clearing a stalled ad hoc task queue touches logs, cron identity, plugins, backups and change records at the same time. Each of the risks below can turn a routine fix into a data exposure or a restore problem, so they should be reviewed before anyone runs a reset or removes a plugin.

Log content with sensitive data

Failed task output and stack traces can contain user names, email addresses, file paths and parts of request data. Moodle 5.1 always logs a stack trace for failed tasks, so the log volume and content you collect will change after an upgrade. Before you copy logs into a ticket or share them with a plugin vendor, check who can read the log tables and the files your task output is written to, and redact personal data first.

Moodle 5.1 notes

Cron running as the wrong user

Cron that runs the task queue as root or as a different account than the web server can leave files in moodledata owned by the wrong user. Those files then block later web requests, backups and cache writes, and the symptom looks like a new stall. Confirm the PHP user in your scheduler, check ownership of moodledata after a manual run, and document the account so that anyone running the CLI uses the same one.

Uncontrolled plugin removal

Deleting or disabling a plugin that owns a queued task can leave orphaned tasks that fail on every run. Removing a plugin from the CLI or the admin interface without first checking which tasks it registered can also drop data the plugin stored. Record the plugin version, list its pending tasks, and get sign-off from the plugin owner before removal, since a blocked queue is often fixed by a patch rather than a removal.

Data loss from resetting mid-backup

Resetting the fail delay or forcing a stalled backup task to run again can leave a partial backup file or a half-written restore in progress. A reset is safe only when you know whether the task is still running in another process. Check for active cron processes, confirm the backup target has space, and keep the last complete site backup until the queued job is verified as finished.

Evidence of queue changes

Manual resets, runner additions and plugin changes are operational changes that auditors and incident responders may later ask about. Without a record, you cannot show who reset a task, when the queue was cleared or which configuration was in place. Keep a change record that notes the task, the action, the operator, the time and the log excerpt used as the reason, and store it where your change process already lives.

Shared resources during recovery

Adding runners to drain a backlog raises database connections, file I/O and memory use, which can slow interactive sessions while the queue is cleared. Long-running tasks compete with users during term peaks. Agree a window for queue work, cap the number of concurrent runners, and watch database load so that recovery does not become a second outage.

Questions teams ask before fixing a Moodle task backlog

How much effort does fixing a Moodle ad hoc task backlog usually take?

Effort depends mainly on why the queue stalled, not on how many tasks are waiting. A backlog caused by a single failing plugin task can often be diagnosed and cleared in a short session, while a backlog caused by slow backups, undersized runners or a database under load needs measurement, configuration changes and retesting. The drivers to scope are the number of task types involved, whether logs are already kept, how many environments need the same fix, and whether a custom or third-party plugin is involved. Ask any partner for a written scope that names the diagnostic steps, the changes, and the verification that a notification, course copy or backup completes as expected.

Can our Moodle administrators clear a backlog without outside help?

Often yes, for the first pass. Administrators can review the ad hoc task queue and the failure information, identify the task class that keeps failing, and check whether a fail delay is set. Moodle 5.0 displays the ad hoc task fail delay and allows it to be reset, and Moodle 5.1 always logs a stack trace for failed tasks, which makes the cause easier to trace. Outside help becomes more useful when the failing task belongs to a third-party plugin, when the cause is in the database or PHP configuration, or when the same problem returns after a reset. Confirm your Moodle version first, because these features depend on it.

What do we need to provide for a backlog investigation?

A useful investigation needs access and evidence. Plan for these items before work starts:

  • Read access to the Moodle site's administration pages, including the ad hoc task queue and the site logs, and the Moodle version and installed plugin list
  • Server logs from the web server, PHP and the cron process, plus the database engine's slow query or error logs where available
  • Shell access to the server running cron or the task runners, with the PHP user identified
  • A test copy of the site or a staging environment where a reset or runner change can be tried first
  • A change window agreed with the business owners of notifications, course copies and backups

Ask for these items to be listed in the written scope so the team knows what to prepare.

How long does it take to clear a Moodle task backlog?

Duration depends on the root cause and on how quickly the cause can be reproduced. A stuck queue caused by one failing task can be unblocked as soon as the failing task is identified and handled. A backlog that grows because tasks run longer than the interval between runs needs more time, because runner capacity, task design and database performance have to be measured. Testing, change control and the time to observe the queue over several cron cycles also add time. No duration is supplied here, so ask a partner for a timeline that separates diagnosis, change, and a monitoring period after the fix.

Which plugin is most often blocking the queue?

There is no single culprit, and any answer should come from your own logs. Blocking usually comes from a task that throws an error on every run, a task that holds a lock or runs too long, or a plugin that queues large volumes of work, such as notifications or course copies. Check the task class name recorded against each failed task, then compare it with the list of installed plugins and their versions. Third-party plugins that have not been tested against your Moodle version are a common starting point for review, so confirm compatibility with the plugin's maintainers before changing it.

When should we bring in outside help for a Moodle backlog?

Bring in outside help when the cause is not visible in your own logs, when the backlog returns after a reset, or when the fix would change core code or a plugin that your team does not maintain. Help is also worth considering when a backlog affects a live teaching period, when several environments need the same change, or when the site must show evidence of how the change was tested. DeployOpen implements and supports self-hosted open-source platforms inside your own infrastructure, and runs fixed-scope engagements agreed in writing before work starts. Ongoing support is available as a retainer for sites that need continued cover.

Does clearing the backlog need a change window or downtime?

Usually not for diagnosis, but some changes do need planning. Reading logs and the task queue is non-disruptive. Adding a runner, changing a cron schedule, or resetting a failing task can affect running jobs, so these should be tested on a copy first and carried out in an agreed window. Upgrading Moodle or a plugin to fix a task is a larger change with its own requirements. For example, Moodle 5.1 requires 64-bit PHP 8.2 or later and a document root pointing to the /public directory, so confirm the server stack before any version change.

How DeployOpen scopes and supports Moodle task troubleshooting

DeployOpen approaches ad hoc task backlogs as an operations problem with a defined evidence trail: we read the queue, the task logs and the plugin code paths before changing anything. The work runs inside your own Moodle, servers and database, and ends with a documented runbook your team can operate.

How we scope

  • Engagements are fixed-scope, with the queue症状, affected task types and environments agreed in writing before work starts.
  • The written scope states which Moodle version, hosts, cron setup and plugins are covered by the troubleshooting work.
  • Ask the quote to separate the one-time diagnosis from any recurring monitoring or retainer support you choose.

How we build

  • We review ad hoc task records, fail delays and stack traces to identify which task class is holding the queue.
  • We test fixes in a staging copy of your site, including runner count changes and any change to plugin task code.
  • Each change is logged with the before and after queue state so the result can be checked against the evidence.

How we hand over

  • You receive a runbook covering queue inspection, fail delay resets, runner setup and the log locations used in diagnosis.
  • Findings name the blocking plugin or task, the evidence behind it and the recommended owner for the fix.
  • Your team walks through the runbook with us so the next stall can be diagnosed without an outside engineer.

How we support

  • Ongoing support, upgrades and continuous checks are available as retainers after the initial engagement ends.
  • A retainer can cover watching the queue after Moodle upgrades and plugin updates, which often change task behavior.
  • Ask for the response expectations and the change process in writing before you agree a support arrangement.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.