This should be fairly simple to implement: a task cancellation button. A task that has yet to be processed could be removed from the queue with a single DELETE. We should make sure that we delete the task only if it has not been started, so some kind of locking, at the DB layer would need to happen. Maybe it could simply be based on the status:

DELETE FROM `tasks` WHERE tid = %d AND status = 'QUEUED'

Maybe a DELETE is a bit brutal and we should do this instead:

UPDATE `tasks` SET status='CANCELED' WHERE tid = %d AND status = 'QUEUED';

The cancel will succeed only if that succeeded.

The task processor should, on its side, do the following immediatly when starting processing:

LOCK TABLE `tasks` WRITE;
UPDATE `tasks` SET status='PROCESSING' WHERE tid = %d AND status = 'QUEUED';
UNLOCK TABLES;

The processor should go ahead with task processing only if the UPDATE succeeds.

Of course, those statuses are not the real thing, I just don't remember if they are INTs or strings in the database.

Comments

adrian’s picture

Version: 5.x-0.2-alpha1 » 6.x-0.4-alpha3
Status: Active » Fixed
adrian’s picture

I also made it so certain tasks dont require the confirmation pop up anymore either.

avdp’s picture

Hi, this is great. One small remark: Isn't 'cancel' a better describtion than 'stop'?
Since the task hasn't started yet, it's hard to stop it, and it gives the impression that you are stopping a task that is already running which could break stuff.

adrian’s picture

this actually got changed to cancel already in head.

i needed to change the css around this so it all got aligned properly (which is why it was called 'stop' before)

avdp’s picture

ok thanks. I only looked at the image, not the actual code.

Status: Fixed » Closed (fixed)

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

  • Commit 94662a7 on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by adrian:
    Cancel task button. #454452
    

  • Commit 94662a7 on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by adrian:
    Cancel task button. #454452