Fix deadlock danger when atomic ops are done under spinlock.
authorAndres Freund <[email protected]>
Mon, 8 Jun 2020 23:50:37 +0000 (16:50 -0700)
committerAndres Freund <[email protected]>
Thu, 18 Jun 2020 21:12:53 +0000 (14:12 -0700)
commit825d89dda5add2eecdc26fa36365720b22c72b71
treee6e8396fc3fb00c7b62e587caf21ff14ea26ba4d
parente027219f213111743a51e19e9febface5871af76
Fix deadlock danger when atomic ops are done under spinlock.

This was a danger only for --disable-spinlocks in combination with
atomic operations unsupported by the current platform.

While atomics.c was careful to signal that a separate semaphore ought
to be used when spinlock emulation is active, spin.c didn't actually
implement that mechanism. That's my (Andres') fault, it seems to have
gotten lost during the development of the atomic operations support.

Fix that issue and add test for nesting atomic operations inside a
spinlock.

Author: Andres Freund
Discussion: https://postgr.es/m/20200605023302[email protected]
Backpatch: 9.5-
src/backend/storage/lmgr/spin.c
src/test/regress/regress.c