pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix deadlock danger when atomic ops are done under spinlock.
Date: Thu, 18 Jun 2020 21:36:17 +0000
Message-ID: <E1jm2Cn-0006Vl-C4@gemulon.postgresql.org> (raw)

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
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6cc2866c4cdf6a167be1ed9cb0fff9fce55758d6

Modified Files
--------------
src/backend/storage/lmgr/spin.c | 97 ++++++++++++++++++++++++++++-------------
src/test/regress/regress.c      | 52 ++++++++++++++++++++++
2 files changed, 119 insertions(+), 30 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1jm2Cn-0006Vl-C4@gemulon.postgresql.org>
Permalink:  ../E1jm2Cn-0006Vl-C4@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jm2Cn-0006Vl-C4@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de
  Subject: Re: pgsql: Fix deadlock danger when atomic ops are done under spinlock.
  In-Reply-To: <E1jm2Cn-0006Vl-C4@gemulon.postgresql.org>
  References: <E1jm2Cn-0006Vl-C4@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox