Replies: 3 comments
-
Sure, open to contributions for cancelling all instances with a certain task-name. Removing the record from the database for an execution that is currently executing will result in errors when the ComplationHandler runs (after processing is done). To even consider cancelling something that is running, I think we also would need some sort of "force"-flag (i.e. by default not removing running). What happens to the executions currently executing in your case? Are they rescheduled? (and that is the ting you want to avoid?) |
Beta Was this translation helpful? Give feedback.
-
Yes, executions keep going on. Which in itself is not that big an issue. The problem is that they are recurring tasks that are not cleaned up and keep being scheduled. It would be fine if they could run normally but be canceled after execution. The longer explanation of the problem: We use event sourcing to create the recurring tasks. In this case, we refactored and this also changed the data object for the job. By hitting reset, we expected we could remove all current jobs, with the code above. By replaying all the events, we should end up with the correct recurring tasks. But now, some of the tasks that were running at the time we hit the reset, are still causing errors because they haven't been removed. So being able to set something like a flag for removal on the running tasks would be good enough. That way all running tasks will be canceled once they ran. |
Beta Was this translation helpful? Give feedback.
-
For anyone seeing this, please upvote, and I might make time to create a PR. We are working around it for now, which is not so pretty but takes less time. The workaround was specific to our problem, so it is not something that can be shared. It comes down to keeping a 'version' of the task, which is additional data we set in the payload of the job. This way, we always know when an 'old' task is executed, and we know we can ignore and cancel that task. |
Beta Was this translation helpful? Give feedback.
-
What is the best way to cancel all tasks with a certain name?
We now have something like:
But
fetchScheduledExecutions
will skip the current running executions. We also run with multiple nodes, so it will miss some of them even if we pause the scheduler before looping through it. The other nodes will still have tasks running. I wonder if there is currently a better way. Or if you are open to creating a PR that allows easy cancellation of all tasks with a certain name.Beta Was this translation helpful? Give feedback.
All reactions