2 ms·
How does one get serializable in a multi-writer system without a lot more locking and having to retry at app layer?
by paulryanrogers 3y ago
How does one get serializable in a multi-writer system without a lot more locking and having to retry at app layer?
- Diggsey 3y agoYou always need app-level retries for SERIALIZABLE isolation level. You don't need any explicit locking - the database should handle that for you (and in the case of PostgreSQL, locking is not the only tool it uses for avoiding serialization anomalies). The strategy I use is to keep transactions as small as possible, and have retry functionality built into the transaction abstraction, so the buesiness logic doesn't really need to worry about it. I also explicitly use read-only transactions where possible.