by maxbond · 3y ago · 0 comments
---
The article is correct. That section contains this snippet:
lock table accounts;
The default lock mode for LOCK is ACCESS EXCLUSIVE, which will prevent concurrent reads. ACCESS EXCLUSIVE (AccessExclusiveLock)
Conflicts with locks of all modes [...]. This mode guarantees that the holder is the only transaction accessing the table in any way.
https://www.postgresql.org/docs/current/explicit-locking.htm...> Now, other transactions won’t be able to read this row until our transaction is committed or rolled back (for update can only be used inside a transaction).
Finally if transaction isolation is SERIALIZABLE, then a row lock can block normal SELECT reads. This is a consequence of SERIALIZABLE isolation preventing write skew. Transactions can be run in parallel, but there has to be some ordering of transactions that produces the same result as if each transaction was one run one at a time.