Skip to content

Race condition #178

@bryanlarsen

Description

@bryanlarsen

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. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions