-
Improvement
-
Resolution: Fixed
-
Minor
-
3.11.4, 3.11.7, 4.0
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
MOODLE_401_STABLE
-
MDL-73293-master -
Install test tasks:
https://github.com/catalyst/moodle-tool_testtasks
Queue up a long running task:
php admin/tool/testtasks/cli/queue_adhoc_tasks.php -d=100
Now run it:
php admin/cli/adhoc_task.php -e
Then kill the process to simulate a kill -9 or a container reap. The adhoc tasks table will still have a non null timestarted which means it thinks it is still running when you visit:
/admin/tool/task/runningtasks.php
There isn't much we can do about preventing it, but we can clean up the metadata after the fact.
Proposing:
1) we introduce a new scheduled task which can be run relatively infrequently
2) all it does it look for all adhoc or scheduled tasks which clai to have been running for a long time, such as more than an hour
3) Attempt to gain a lock for the task with a 0 timeout. If the lock can be gained then we know the task isn't running and we can clean up the metadata.