travis-ci/travis-core — pull request #333 by drogus (2014-01-23 17:14:47+00:00)
Title: Use serializable transaction when adding new builds

From commit message:

```
Serializable transaction isolation level simulates serial transaction
execution, which will ensure that build numbers are unique. One of the
drawbacks of using serializable isolation level is that it can fail with
increased concurrency - that's why it's good to try retrying adding a
new build.
```

I'm not sure if there is any good way to test it. I've created a small script which tries to simulate concurrency in similar setting: https://gist.github.com/drogus/e445560ab26cb4fc59b3, it handles concurrency of 30 without failing to create a build, so we should be fine.

A better thing to do would be to create unique index, but that would mean renumbering existing builds. We may do this in the future, but meanwhile we can use this fix.