adonisjs / lucid

AdonisJS SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
https://lucid.adonisjs.com/
MIT License
1.02k stars 189 forks source link

V5: Repeatable read isolation doesn't work as expected #1006

Open mkevison opened 4 months ago

mkevison commented 4 months ago

Package version

5.9.0

Describe the bug

I'm running some tests with isolation in Postgres

I create a transaction with the isolation type repeatable read

const firstTransaction = await Database.connection(connection).transaction({
       isolationLevel: 'repeatable read',
})

After that, I perform a query using the newly created transaction.

Through a second transaction, before committing the firstTransaction, I read, update and commit the data read by the firstTransaction

After changes using the second transaction I update the same data again using the firstTransaction

What is expected is that the firstTransaction commit gives an error and that is not what is happening, the commit passes normally

I simulated this through two Postgres terminals and it worked as expected, the firstTransaction after reading and changing the data does not accept the commit if this data is changed by another transaction before its commit

Note: I am correctly using firstTransaction when reading and changing data

Reproduction repo

https://github.com/mkevison/repeatable-read