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

Possible race condition? #9

Closed
romanbsd opened this issue May 22, 2015 · 4 comments
Closed

Possible race condition? #9

romanbsd opened this issue May 22, 2015 · 4 comments

Comments

@romanbsd
Copy link

I read the code, and couldn't figure out, how you handle a race condition when job C is dependent on jobs A and B which finish at the same time.

@pokonski
Copy link
Contributor

Are you able to reproduce the issue? A sample code which fails would be helpful. I tested with hundreds of thousands jobs running in parallel (empty jobs to make sure they run and finish at the same time), but the issue never occurred.

Every job has a key in Redis, after the job finishes it gets marked in that key.
When A finishes, it marks itself as finished and checks if there are any child jobs with satisfied dependencies. If there are, then it queues them.
Same thing with B.

So if A finishes slightly sooner, it doesn't trigger child job since B is running.
And if B finishes last, then C's dependencies are satisfied and it gets queued.

@romanbsd
Copy link
Author

No, it's a completely theoretical question. I'm still wondering what would happen if they finish at precisely the same time.

@pokonski
Copy link
Contributor

If they do finish at precisely the same time, then it is possible.

That said, I probably should add some mutex to job enqueuing to make sure they don't get enqueued twice. 👍

Thanks for bringing this up :)

@pokonski
Copy link
Contributor

Closing as this wasn't actually spotted in actual apps using Gush.

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

No branches or pull requests

2 participants