pgsql: Add an isolation test to exercise parallel-worker deadlockresol - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Add an isolation test to exercise parallel-worker deadlockresol
Date
Msg-id E1htDLI-00088F-To@gemulon.postgresql.org
Whole thread Raw
List 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(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Add error codes to some corruption log messages
Next
From: Peter Geoghegan
Date:
Subject: pgsql: Add sort support routine for the inet data type.