Skip to content
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

Use a transaction when enqueuing a job to ensure atomicity #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marianstefi20
Copy link

Suppose the scheduler receives a SIGKILL. If this happens between zrem and zadd in enqueue_job() the repeatable or cron jobs might stop working properly altogether. This is because the job is first consumed from Redis and later added in the sorted set with a score that's the future time at which it will run.

To solve this, I propose using a transaction in enqueue_job. This would assure the atomicity of the sequence of operations.

pipe.execute()
return

next_scheduled_time = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the rationale behind changing the way which next_scheduled_time calculation is different than the current implementation?

@selwin
Copy link
Contributor

selwin commented Apr 24, 2020

Sorry for the late reply, I'd like to get this merged in if you could just address my comment here: #223 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants