Debugging Rspec Postgres lockups Debugging Rspec Postgres lockups postgresql postgresql

Debugging Rspec Postgres lockups


If you are running parallel rspec tasks, that could be triggering this. When we've run into issues like this, we have forced those tests to run in single, non-parallel instance of rspec in our CI using tags.

Try something like this:

  context 'when both records get updated in one job', non_parallel do    it { is_expected.to eq 2 }  end

And then invoke rspec singularly on the non_parallel tag:

  rspec --tag non_parallel

The bulk of your tests (not tagged with non_parallel) can still be run in parallel in your CI solution (e.g. Jenkins) for performance.

Of course, be careful applying this band-aid. It is always better to identify what is not race-safe in your code, since that race could happen in the real world.