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

Race condition #178

Open
bryanlarsen opened this issue Aug 8, 2018 · 0 comments
Open

Race condition #178

bryanlarsen opened this issue Aug 8, 2018 · 0 comments

Comments

@bryanlarsen
Copy link

bryanlarsen commented Aug 8, 2018

We're starting to see jobs showing up in the wrong tube in production.

It appears to be a race condition. Our code looks like this:

stalk.use(tube, function(err, tubename) {
  if(err) ...
  stalk.put(...)
}

And of course stalk.use does IO so node schedules before calling the callback, opening up an opportunity for a race condition if another request also calls stalk.use.

I imagine that's how a good number of people have their code structured. To prevent the race condition, we need to either call use & put sequentially without a potential schedule between them, or we need to use a different stalk connection per tube.

A use_and_put function would make the first easier for people, and also make the problem more obvious.

Regardless of solution, the README should probably warn people not to do what I did. :)

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

No branches or pull requests

1 participant