The task queue can be configured with the number of tasks to be started ('$limit') each time the queue is checked. For efficient operation of a siginficant Aegir installation, it is necessary to have this '$limit" value higher than 1.
The current implementation will select the oldest '$limit' outstanding tasks in the queue and start them running. Now, if there is more than one task in this set for a particular site, then there could be a conflict during task execution. It would be desirable to ensure that the list of '$limit' tasks did not have more than one for any particular site to avoid such potential conflicts.
The tasks to be started are selected by the following SQL statement in function _hosting_get_new_tasks (in file hosting.queues.inc)
$result = db_query("SELECT t.nid FROM {hosting_task} t INNER JOIN {node} n ON t.vid = n.vid WHERE t.task_status = %d ORDER BY n.changed, n.nid ASC LIMIT %d", 0, $limit);
If this statement is changed by the addition of a "GROUP BY" clause, then only one task for each site will appear in the resulting list.
$result = db_query("SELECT t.nid FROM {hosting_task} t INNER JOIN {node} n ON t.vid = n.vid WHERE t.task_status = %d GROUP BY t.rid ORDER BY n.changed, n.nid ASC LIMIT %d", 0, $limit);
I recommend that this change is included in the hosting module.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | hosting-Only-one-task-per-site-1472480-0.patch | 786 bytes | jayelless |
Comments
Comment #1
jayelless commentedHere is a patch to effect the proposed change.
I have also changed the category from "feature request" to "bug report" as I have experienced task failures as a consequence of more than one task running on the same site simultaneously.
Comment #2
steven jones commentedThanks very much for the patch, committed to 6.x-1.x as commit:b9ca31cfa57c24bee872816901a7c0a641956e79
Comment #3
steven jones commentedAnd in 6.x-2.x as 24a11293bdbdfd640a7f99f024d4929bb40f7e6d.
Comment #4
Robin Millette commentedI am not seeing the commit anywhere, on any branch. Links in #2 and #3 are 500 internal errors.
Comment #5
steven jones commentedYeah, I've not pushed them yet, will in a bit.
Comment #6
Robin Millette commentedIndeed, works now. I'll be more patient next time. Thanks!
Comment #7
steven jones commentedReally sorry that I forgot to give you attribution on the git commit itself, I usually remember to, sorry!