Re:Testing Postgres race conditions with synchronization bar...
by lirbank on Monday February 16, 2026 @05:12PM
(#47041038)
Nice - that's a good case for barriers too. When there's no row to SELECT FOR UPDATE against, you'd inject the barrier after acquiring the advisory lock and verify the second transaction blocks until the first commits.
Re:Testing Postgres race conditions with synchronization bar...
by klysm on Monday February 16, 2026 @06:21PM
(#47041679)
Seems like a good way to materialize the conflict.
Re:Testing Postgres race conditions with synchronization bar...
by deepsun on Monday February 16, 2026 @07:01PM
(#47041990)
I always did "INSERT ... ON CONFLICT DO NOTHING".
Advisory locks let you serialize on an arbitrary key (like a hash of the entity type + parent ID) without needing a dummy row or separate lock table. They auto-release on transaction end, so no cleanup.
The barrier testing approach from the article would work nicely here too - inject the barrier between acquiring the advisory lock and the subsequent insert, then verify the second transaction blocks until the first commits.