tsql icon indicating copy to clipboard operation
tsql copied to clipboard

Consider making default IsolationLevel REPEATABLE_READ

Open AnyhowStep opened this issue 5 years ago • 3 comments
trafficstars

Right now, the default with this library is SERIALIZABLE.

The problem here is that this causes deadlocks really easily.

How often do people really need SERIALIZABLE, vs the more relaxed REPEATABLE_READ?

AnyhowStep avatar May 06 '20 13:05 AnyhowStep

With REPEATABLE_READ, you can still have deadlocks and timeouts, but this should only happen with long-lived transactions.

And, usually, you shouldn't have long-lived transactions. They should be small and quick.


SERIALIZABLE transactions can give you deadlocks, even for very short transactions.


Changing the default is technically a major breaking change.

AnyhowStep avatar May 06 '20 14:05 AnyhowStep

However, the SQL standard does say the default is SERIALIZABLE...

And MySQL uses REPEATABLE_READ, while PostgresQL uses READ_COMMITTED...

AnyhowStep avatar May 06 '20 14:05 AnyhowStep

Maybe transactions in the library shouldn't have a default isolation level at all, and should force users to carefully think about the isolation level they want

AnyhowStep avatar May 06 '20 14:05 AnyhowStep