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.

Comments

jayelless’s picture

Category: feature » bug
Status: Active » Needs review
StatusFileSize
new786 bytes

Here 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.

steven jones’s picture

Status: Needs review » Fixed

Thanks very much for the patch, committed to 6.x-1.x as commit:b9ca31cfa57c24bee872816901a7c0a641956e79

steven jones’s picture

Robin Millette’s picture

I am not seeing the commit anywhere, on any branch. Links in #2 and #3 are 500 internal errors.

steven jones’s picture

Yeah, I've not pushed them yet, will in a bit.

Robin Millette’s picture

Indeed, works now. I'll be more patient next time. Thanks!

steven jones’s picture

Really sorry that I forgot to give you attribution on the git commit itself, I usually remember to, sorry!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 24a1129 on 6.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by Steven Jones:
    Issue #1472480 by jlscott: Fixed Restrict the Task Queue to one task per...

  • Commit 24a1129 on 6.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by Steven Jones:
    Issue #1472480 by jlscott: Fixed Restrict the Task Queue to one task per...