Scheduled Tasks Proposal: Difference between revisions
Penny Leach (talk | contribs) |
Penny Leach (talk | contribs) No edit summary |
||
Line 18: | Line 18: | ||
== Goals == | == Goals == | ||
* | * Centralised locking for *all* tasks | ||
* | * A way consistent for *all plugin types* to register with Moodle (at installation/upgrade) when they want their jobs run | ||
* More sophisticated scheduling rather than just intervals in seconds (eg every sunday at 11pm or similar) based on unix cron | |||
* An administration screen in Moodle to allow site administrators to adjust the scheduling of individual tasks | |||
== Approach == | |||
== Unresolved issues == | === Database === | ||
=== Module cron registration === | |||
=== Locking === | |||
== Unresolved issues/ideas == | |||
* Do we need to allow for scheduling different subtasks on different servers? | * Do we need to allow for scheduling different subtasks on different servers? | ||
Line 29: | Line 38: | ||
* When the first cron in a long time is running, we should lock the entire cron and let it run to completeness, because the order is really important then. | * When the first cron in a long time is running, we should lock the entire cron and let it run to completeness, because the order is really important then. | ||
== Psuedo code proposal == | |||
Moved to the talk page | Moved to the talk page | ||
Revision as of 23:07, 4 January 2010
Moodle 2.0
Introduction
This proposal is meant both to provide a replacement for the moodle cron job, and provide a means to schedule once off tasks to be run outside of the user's request lifecycle.
Terminology
- *Subtask* an individual piece of cron processing that should be run (equivalent to forum_cron now, or maybe even smaller)
- *Moodle cron instance* a cron.php process
Rationale
The moodle cronjob currently delegates all scheduling to each subtask that is run - for example, the forum cron is responsible for checking when it last run, and making decisions about whether or not it should be run again. This sort of decision process should be centralised, and individual cron subtasks should be called by the central controller.
Additionally, there is not any central locking of subtasks. At the moment, some subtasks that expect that they might take a long time to run implement their own locking (for example statistics), but it's not centralised. Each moodle cron instance runs to completion, no matter how long it takes, and it processes tasks in the order that they're programmed, regardless of if there are any other moodle cron instances running, that might be processing sub tasks in parallel
Finally, we need to be able to run non-related tasks in parallel so that the entire moodle queue isn't held up by single long running jobs.
Goals
- Centralised locking for *all* tasks
- A way consistent for *all plugin types* to register with Moodle (at installation/upgrade) when they want their jobs run
- More sophisticated scheduling rather than just intervals in seconds (eg every sunday at 11pm or similar) based on unix cron
- An administration screen in Moodle to allow site administrators to adjust the scheduling of individual tasks
Approach
Database
Module cron registration
Locking
Unresolved issues/ideas
- Do we need to allow for scheduling different subtasks on different servers?
- We need to find a way to separate subtasks by some logic so that subtasks that write to the same areas of the database never run at the same time. We could do this by getting each cron job to say what areas of Moodle they write to, but this is problematic.
- We also have to deal with the order of some subtasks - we could maybe do this by introducing dependencies
- When the first cron in a long time is running, we should lock the entire cron and let it run to completeness, because the order is really important then.
Psuedo code proposal
Moved to the talk page
Audit of current cron
Main section | Subtask | Frequency | Notes |
---|---|---|---|
session_gc | every run | ||
mod/assignment | plugins (none) | every minute | |
mod/assignment | message submissions | every minute | checks last run time |
mod/chat | update chat times | every five minutes | |
mod/chat | update_events | every five minutes | |
mod/chat | delete old chat_users and add quits | every five minutes | |
mod/chat | delete old messages | every five minutes | |
mod/data | every minute | no _cron function (includes file unnecessarily) | |
mod/forum | mail posts | every minute | checks last run time |
mod/forum | digest processing | every minute | |
mod/forum | delete old read tracking | every minute | |
mod/scorm | reparse all scorms | every five minutes | does hourly checking |
mod/wiki | delete expired locks | every hour | |
blocks/rss_client | update feeds | every five minutes | |
quiz/report/statistics | delete old statistics | every run | |
admin/reports | none | every run | |
language_cache | every run | ||
remove expired enrolments | every run | ||
main gradebook | lock pending grades (*2) | every run | |
main gradebook | clean old grade history | every run | has a TODO to not process as often |
event queue | every run | potentially large | |
portfolio cron | clean expired exports | every run | potentially large |
longtimenosee | 20% | ||
deleteunconfirmedusers | 20% | ||
deleteincompleteusers | 20% | ||
deleteoldlogs | 20% | ||
deletefiltercache | 20% | ||
notifyloginfailures | 20% | ||
metacourse syncing | 20% | ||
createpasswordemails | 20% | ||
tag cron | 20% | ||
clean contexts | 20% | ||
gc_cache_flags | 20% | ||
build_context_path | 20% | ||
scheduled backups | daily (admin defined) | ||
make rss feeds | every run | ||
auth/mnet | keepalives | every run | |
auth/mnet | delete old sessions | every run | |
auth/ldap | sync users | custom | not scheduled (external cronjob) |
auth/cas | sync users | custom | not scheduled (external cronjob) |
auth/db | sync users | custom | not scheduled (external cronjob) |
enrol/authorize | clears old data | daily (admin defined) | |
enrol/authorize | notifies administrators of old data | daily (admin defined) | |
enrol/authorize | process orders & email teachers | every run | |
enrol/flatfile | read file and sync users | every run | !?! |
enrol/imsenterprise | read file and sync users | every run | !?!?! |
enrol/manual | notify people of pending unenrolments | daily | |
statistics | daily (admin defined) | huge | |
grade/import | none | every run | |
grade/export | none | every run | |
grade/reports | none | every run | |
fetch blog entries | every run | ||
file gc | (optional) daily, else every run? | ||
local cron |