At some point we moved to creating a new task node for each instance of a task being triggered. The 'Cancel' function doesn't work, however. The mechanism, in hosting_task_cancel(), appears to be adding a task with an error status. Presumably, this is intended to update the existing task, and thus block it from executing. This no longer works. The result of clicking the 'Cancel' button, is now to just insert a cancelled task into the queue. It does not update the existing task. So we end up with a pending task, followed by a cancelled/error task of the same type.

Comments

ergonlogic’s picture

This looks like it was a bug in hosting_get_most_recent_task(), where it never returned an existing task. This appears to be why we create new task nodes every time we trigger a task now.

I believe that "fixing" hosting_get_most_recent_task() might be detrimental, as Views, among other things now assume a task node per instance of the task being run. Still, I think the previous functionality makes sense resource-wise. Having a new node, rather than just a revision, every time a task is triggered might be overkill...

ergonlogic’s picture

After experimenting with moving back to a single node per task (per site/platform/server), I think this is a dead-end. Essentially, with our task lists, we can either have a single entry per task per site/platform/server, or every revision, which ends up including each stage of a task (queued then completed/cancelled/...) We could try to add a Views filter to remove certain 'queued' revisions, or somehow link 'queued' revisions to their results, but that basically re-invents the node-based system we have now.

ergonlogic’s picture

So yeah... node per task instance makes everything much easier. This is fixed by just updating the task $node->task_status. I also took this opportunity to flag cancellations as 'warnings' rather than errors.

ergonlogic’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

helmo’s picture

Removing the hosting_get_most_recent_task function led to a failure in the Hosting Site Backup Manager... #2755693: Call to undefined function hosting_get_most_recent_task

I've restored that function now. http://cgit.drupalcode.org/hosting/commit/task/hosting_task.module?id=31...