pgsql: Add an isolation test to exercise parallel-worker deadlock resol

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add an isolation test to exercise parallel-worker deadlock resol
Date: 2019-08-01 15:50:12
Message-ID: E1htDLI-00088F-To@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add an isolation test to exercise parallel-worker deadlock resolution.

Commit a1c1af2a1 added logic in the deadlock checker to handle lock
grouping, but it was very poorly tested, as evidenced by the bug
fixed in 3420851a2. Add a test case that exercises that a bit better
(and catches the bug --- if you revert 3420851a2, this will hang).

Since it's pretty hard to get parallel workers to take exclusive
regular locks that their parents don't already have, this test operates
by creating a deadlock among advisory locks taken in parallel workers.
To make that happen, we must override the parallel-safety labeling of
the advisory-lock functions, which we do by putting them in mislabeled,
non-inlinable wrapper functions.

We also have to remove the redundant PreventAdvisoryLocksInParallelMode
checks in lockfuncs.c. That seems fine though; if some user accidentally
does what this test is intentionally doing, not much harm will ensue.
(If there are any remaining bugs that are reachable that way, they're
probably reachable in other ways too.)

Discussion: https://postgr.es/m/3243.1564437314@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
src/backend/utils/adt/lockfuncs.c | 29 --------
src/test/isolation/expected/deadlock-parallel.out | 47 ++++++++++++
src/test/isolation/isolation_schedule | 1 +
src/test/isolation/specs/deadlock-parallel.spec | 89 +++++++++++++++++++++++
4 files changed, 137 insertions(+), 29 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Shay Rojansky 2019-08-01 16:33:52 Re: UCT (Re: pgsql: Update time zone data files to tzdata release 2019a.)
Previous Message Tom Lane 2019-08-01 14:08:01 Re: UCT (Re: pgsql: Update time zone data files to tzdata release 2019a.)