relstorage.adapters.postgresql.locker – Locker implementations#
- class PostgreSQLLocker(options, driver, batcher_factory)#
On PostgreSQL, for locking individual objects, we use advisory locks, not row locks.
This is because row locks perform disk I/O, which can “bloat” tables; this is especially an issue for shared (readCurrent) locks, which perform I/O to pages that might not otherwise need it. Using many row locks requires a good (auto)vacuuming setup to prevent this bloat from becoming a problem.
Also, advisory locks are much faster than row locks.
We take advisory locks based on OID. OIDs begin at 0 and increase. To avoid conflicting with those, any advisory locks used for “administrative” purposes, such as the pack lock, need to use negative numbers.
-1: The commit lock
-2: The pack lock
Try to acquire the pack lock.
Raise an exception if packing or undo is already in progress.
Release the pack lock.