]> granicus.if.org Git - postgresql/commit
Add an isolation test to exercise parallel-worker deadlock resolution.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 1 Aug 2019 15:50:00 +0000 (11:50 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 1 Aug 2019 15:50:00 +0000 (11:50 -0400)
commitda9456d22a7697ef2c5ba9dd1402d948b2ec7f09
treec0f0085bba4ed4bcb513552fd8bfa442c8837b8d
parent4886da8327507dddd830786b0c7aaa9cfc480b4b
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
src/backend/utils/adt/lockfuncs.c
src/test/isolation/expected/deadlock-parallel.out [new file with mode: 0644]
src/test/isolation/isolation_schedule
src/test/isolation/specs/deadlock-parallel.spec [new file with mode: 0644]