pgsql: Fix deadlock danger when atomic ops are done under spinlock.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix deadlock danger when atomic ops are done under spinlock.
Date: 2020-06-18 21:36:31
Message-ID: E1jm2D1-0006Xr-2m@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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-

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3e69bf3b142be3f4205435ef3baabcae168c6a14

Modified Files
--------------
src/backend/storage/lmgr/spin.c | 99 +++++++++++++++++++++++++++++++----------
src/test/regress/regress.c | 47 +++++++++++++++++++
2 files changed, 123 insertions(+), 23 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-06-18 21:44:47 Re: pgsql: Add basic spinlock tests to regression tests.
Previous Message Andres Freund 2020-06-18 21:36:27 pgsql: Fix deadlock danger when atomic ops are done under spinlock.