Home > Blockchain >  Conflict on two PostgreSQL transactions with serializable isolation level
Conflict on two PostgreSQL transactions with serializable isolation level

Time:10-19

I have two concurrent SQL transactions with the most strict level of isolation (serializable)

According to Conflict on two Postgres transactions with serializable isolation level

CodePudding user response:

The SQL Server documentation is clearly not relevant.

But yes, that looks like a PostgreSQL bug that you should report. But please with an SQL script, not with an animated GIF...

CodePudding user response:

This is a consequence of the way Postgres provides system catalogs. The relevant note in the documentation is clear enough:

Internal access to the system catalogs is not done using the isolation level of the current transaction. This means that newly created database objects such as tables are visible to concurrent Repeatable Read and Serializable transactions, even though the rows they contain are not.

The example you provided does not break the cited rules about the serializable isolation level. Note, that you start the second transaction when the table was dropped and created by the first transaction. The resulting behavior is as expected.

If you had started both transactions before the table was dropped, then one of them would be suspended until the other completes.

  • Related