pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Munro <tmunro@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix lock assertions in dshash.c.
Date: Mon, 11 Jul 2022 04:47:47 +0000
Message-ID: <E1oAlKj-002Dm5-RF@gemulon.postgresql.org> (raw)

Fix lock assertions in dshash.c.

dshash.c previously maintained flags to be able to assert that you
didn't hold any partition lock.  These flags could get out of sync with
reality in error scenarios.

Get rid of all that, and make assertions about the locks themselves
instead.  Since LWLockHeldByMe() loops internally, we don't want to put
that inside another loop over all partition locks.  Introduce a new
debugging-only interface LWLockAnyHeldByMe() to avoid that.

This problem was noted by Tom and Andres while reviewing changes to
support the new shared memory stats system, and later showed up in
reality while working on commit 389869af.

Back-patch to 11, where dshash.c arrived.

Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Reported-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Reviewed-by: Zhihong Yu <zyu@yugabyte.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/20220311012712.botrpsikaufzteyt@alap3.anarazel.de
Discussion: https://postgr.es/m/CA%2BhUKGJ31Wce6HJ7xnVTKWjFUWQZPBngxfJVx4q0E98pDr3kAw%40mail.gmail.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cd26139a305658afedd8931359ff9aadfe4b973b

Modified Files
--------------
src/backend/lib/dshash.c          | 37 ++++++++++---------------------------
src/backend/storage/lmgr/lwlock.c | 26 ++++++++++++++++++++++++++
src/include/storage/lwlock.h      |  1 +
3 files changed, 37 insertions(+), 27 deletions(-)



view thread (6+ messages)

Message-ID: <E1oAlKj-002Dm5-RF@gemulon.postgresql.org>
Permalink:  ../E1oAlKj-002Dm5-RF@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oAlKj-002Dm5-RF@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: tmunro@postgresql.org
  Subject: Re: pgsql: Fix lock assertions in dshash.c.
  In-Reply-To: <E1oAlKj-002Dm5-RF@gemulon.postgresql.org>
  References: <E1oAlKj-002Dm5-RF@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