sequenced icon indicating copy to clipboard operation
sequenced copied to clipboard

Avoid acquiring full table locks in PostgreSQL

Open davidcelis opened this issue 2 years ago • 0 comments

As noted in #58, full table locks are dangerous and can be avoided by acquiring locking only records associated to the parent. This patch uses the build_scope interface to do a quick SELECT 1 FROM ... FOR UPDATE that should work both for scoped and unscoped sequence columns.

Also worth mentioning: I didn't touch the tests because I'm pretty unsure of the best way to test this, or if modification of our tests is even necessary. If there's a good way to modify the concurrency test so that the lock is exercised, I'm happy to do so. I did verify in our own application that this correctly issues a SELECT ... FOR UPDATE query and avoids the full table lock.

davidcelis avatar Oct 20 '22 01:10 davidcelis