The PostgreSQL manual page on the Serializable Isolation Level states:
[Like] the Repeatable Read level, applications using this level must be prepared to retry transactions due to serialization failures.
What are the conditions for encountering a serialization failure at the Repeatable Read or Serializable levels?
I tried to induce a serialization failure with two instances of psql running, but even though a transaction was committed by one instance, the other instance, inside a serializable-level transaction while the other committed, was successful in committing its changes. Both simply inserted records into a table, so perhaps I need to try something more complex.
Basically I am trying to understand what happens in the event of a serialization failure and how serialization failures arise.
For
REPEATABLE READthis example will do:Prepare stage:
Now keep an eye on the psql-X part indicating the interleaving of actions:
An example for
SERIALIZABLEis in the documentation for PostgreSQL 9.1 and should be no problem from here.