Include queue name in unique task ID generation#181
Open
thomasst wants to merge 3 commits intotask-unique-keyfrom
Open
Include queue name in unique task ID generation#181thomasst wants to merge 3 commits intotask-unique-keyfrom
thomasst wants to merge 3 commits intotask-unique-keyfrom
Conversation
This avoids a "task not found" scenario where we queue a unique task into several queues.
1cff32c to
c7d5897
Compare
| 'kwargs': kwargs, | ||
| } | ||
| if queue is not None: | ||
| data['queue'] = queue |
Contributor
There was a problem hiding this comment.
Any reason not to serialize an explicit null?
Member
Author
There was a problem hiding this comment.
We currently use the same function for to compute the lock ID (in which case we pass None for the queue). It would break existing locks if we serialized an explicit null. I can add a comment for this.
AlecRosenbaum
approved these changes
Mar 22, 2021
jkemp101
approved these changes
Mar 22, 2021
Member
jkemp101
left a comment
There was a problem hiding this comment.
Looks like the unique docs might already suggest this behavior. Should we clarify that the lock is across all queues https://github.com/closeio/tasktiger#task-options.
Member
Author
|
Holding off with this PR for now since it can cause issues with existing deployments: If users rely on canceling scheduled tasks by ID, this will break. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This avoids a "task not found" scenario where we queue a unique task into several queues.
For example, if we queue a unique task with ID X into queues A and B, and the task X finishes on queue A first before being processed by queue B, then the task ID X would still be queued in queue B, but the worker would not be able to find the task since the task key is deleted.
We check (
tasktiger/tasktiger/task.py
Lines 262 to 278 in f48fe03
I believe this shouldn't be a completely incompatible change to roll out since uniqueness isn't the same as locking as you can still queue a unique task even if one is being executed. Its main purpose is to reduce load. TaskTiger doesn't make any guarantees that unique tasks are not executed concurrently, however, in its current implementation it doesn't do that and instead schedules the unique task for later execution if one is already running (
tasktiger/tasktiger/worker.py
Lines 797 to 804 in f48fe03