tsql
tsql copied to clipboard
Consider making default IsolationLevel REPEATABLE_READ
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?
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.
However, the SQL standard does say the default is SERIALIZABLE...
And MySQL uses REPEATABLE_READ, while PostgresQL uses READ_COMMITTED...
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