]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix lock assertions in dshash.c.
authorThomas Munro <tmunro@postgresql.org>
Mon, 11 Jul 2022 02:47:16 +0000 (14:47 +1200)
committerThomas Munro <tmunro@postgresql.org>
Mon, 11 Jul 2022 03:51:47 +0000 (15:51 +1200)
commit4f88dbac22a845a33c758554e25ca0ee7e9dedac
treed33d515170e282ef383cb434757c0dda56f4ee4d
parent09224a35cdaa06f047d2ae1e25595002f27ce303
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
src/backend/lib/dshash.c
src/backend/storage/lmgr/lwlock.c
src/include/storage/lwlock.h