-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include queue name in unique task ID generation #181
base: task-unique-key
Are you sure you want to change the base?
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to serialize an explicit null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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. |
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