It happened on a project I was working on that we had to implement a divide & conquer algorithm using our background jobs processor, in this case we were using sidekiq. Implementing this using sidekiq can be quite challenging since all the workers are independent and they do not trigger any callback once they’re done.
ActiveRecord save race condition in Resque
We have a Rails app that is saving a new ActiveRecord object, and then immediately afterwards, enqueueing a Resque job that looks up that record by its ID. Sometimes, the lookup inside the resque job fails – it claims no such row with that ID exists.
If we put the lookup into a loop that catches that exception and retries the exact same lookup, it always eventually succeeds, usually after 1-2 seconds.
The ID exists on the ActiveRecord object before the job is enqueued, which (I think) means that the save transaction has completed. But the resque job is using a different database connection, so maybe there's some weird caching going on? But here Google has failed us.
Any ideas? We could leave it in a loop that catches the exception, sleeps 1 second, and retries, but: ugh.
Some ideas from the audience:
There is a connection object that can be queried about transaction states.
Wait for transaction count increment/decrement?
Could be a problem with the way that sqlite fakes nested transactions.
Best practices for individual users on GitHub
Usually we have a single GitHub account for a project that contains a key for each of the machines being used on a project. On our project we want to use a separate account for each person on the project. Is there a way to do this without a lot of trouble shuffling SSH keys around?
Pivotal Git Scripts may have some tools for this.
You can also use HTTPS URLs and enter username/password on each commit.
Lobot – Now with per-project chef recipes
If you need to write your own chef recipes to install your project's dependencies, you can add a cookbooks directory to the root of your project. Make sure to delete the cookbook_paths section from your lobot.yml (to use the default values), or add ./chef/project-cookbooks to the cookbook_paths section.
So, to have a bacon recipe, you should have cookbooks/pork/recipes/bacon.rb file in your repository.
Stately – A font of the US states
For all those times you need a vector representation of the USA and to color the states separately.
Apiary – Public API documentation
Takes a well formed file and generates really usable REST API documentation. Integrates with Github for collaboration