Safe Lock Acquisition Should Specifically Target Different Lock Modes
jcoleman opened this issue · comments
Currently safely_acquire_lock_for_table
always acquires an AccessExclusiveLock
, which is generally safe in the sense that:
- It's always sufficient for the operation since it's the highest lock type for a table.
- Most of the places we use it need that high of a lock level anyway.
However, it has a few disadvantages:
- There are some existing places where we don't need that high of a lock level (albeit the operations are still fast, so it hasn't seemed like a big deal).
- We could use it in places where we explicitly do not need a high level lock.
If we change this, we'd need t make sure that nesting calls (or even calls in the same transaction -- even though we discourage that) can't upgrade locks since that's could result in a deadlock.