pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix busted logic for parallel lock grouping in TopoSort().
Date: Mon, 29 Jul 2019 22:49:22 +0000
Message-ID: <E1hsESI-0005Bd-4x@gemulon.postgresql.org> (raw)

Fix busted logic for parallel lock grouping in TopoSort().

A "break" statement erroneously left behind by commit a1c1af2a1
caused TopoSort to do the wrong thing if a lock's wait list
contained multiple members of the same locking group.

Because parallel workers don't normally need any locks not already
taken by their leader, this is very hard --- maybe impossible ---
to hit in production.  Still, if it did happen, the queries involved
in an otherwise-resolvable deadlock would block until canceled.

In addition to removing the bogus "break", add an Assert showing
that the conflicting uses of the beforeConstraints[] array (for both
counts and flags) don't overlap, and add some commentary explaining
why not; because it's not obvious without explanation, IMHO.

Original report and patch from Rui Hai Jiang; additional assert
and commentary by me.  Back-patch to 9.6 where the bug came in.

Discussion: https://postgr.es/m/CAEri+mLd3bpHLyW+a9pSe1y=aEkeuJpwBSwvo-+m4n7-ceRmXw@mail.gmail.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0dcb1c6c4874d2d464d426ded208b58b01e52174

Modified Files
--------------
src/backend/storage/lmgr/deadlock.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1hsESI-0005Bd-4x@gemulon.postgresql.org>
Permalink:  ../E1hsESI-0005Bd-4x@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hsESI-0005Bd-4x@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix busted logic for parallel lock grouping in TopoSort().
  In-Reply-To: <E1hsESI-0005Bd-4x@gemulon.postgresql.org>
  References: <E1hsESI-0005Bd-4x@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