Fix deadlock danger when atomic ops are done under spinlock.
authorAndres Freund <andres@anarazel.de>
Mon, 8 Jun 2020 23:50:37 +0000 (16:50 -0700)
committerAndres Freund <andres@anarazel.de>
Thu, 18 Jun 2020 21:13:26 +0000 (14:13 -0700)
commit5fffa8fce37b981e1a5bb79affce9a856e021265
tree9895748e7224b0f924ec1e53d253154e4802222a
parent59225dcefef278415aef64c3b96f84616b95661e
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.g6v3ydozy5txifji@alap3.anarazel.de
Backpatch: 9.5-
src/backend/storage/lmgr/spin.c
src/test/regress/regress.c