-
|
I love what you're doing here. It's very timely for me as I'm looking to implement a ledger in a system backed by Postgres but, unlike you, this will be my first time! Could you help me understand the appropriate transaction isolation level to use? Does the locking mean it is safe even at default |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I believe it is safe to use at the default The read story is a little different, though. Subsequent reads from the ledger tables may see different results, even within the same database transaction, if other ledger operations have committed (i.e. you don't get a snapshot of the whole database at the beginning of a database transaction). For that, you would need repeatable read:
https://www.postgresql.org/docs/17/transaction-iso.html#XACT-REPEATABLE-READ Please let me know if this helps clarify, or if there are certain scenarios or usage patterns you are worried about. |
Beta Was this translation helpful? Give feedback.
I believe it is safe to use at the default
READ COMMITTEDisolation level. Any updates to the ledger use locking to ensure they run one at a time for affected accounts.The read story is a little different, though. Subsequent reads from the ledger tables may see different results, even within the same database transaction, if other ledger operations have committed (i.e. you don't get a snapshot of the whole database at the beginning of a database transaction). For that, you would need repeatable read: