injection_points: canceled or terminated waiters leak their wait slots - Mailing list pgsql-hackers

From Zsolt Parragi
Subject injection_points: canceled or terminated waiters leak their wait slots
Date
Msg-id CAN4CZFO+KF=cc0-iEg28RhqRBp_fTs6D4b8b7D7DB-pGYP3Ccg@mail.gmail.com
Whole thread
List pgsql-hackers
Hello hackers,

While stress-testing REPACK CONCURRENTLY on 19beta2 I saw a logical
decoding activation race, and I extended 051_effective_wal_level.pl
with a test that waits on an injection point and wakes it up later.
051 cancels two injection point waiters earlier in the script, and
injection_wait() never cleans up after a canceled waiter, the wakeup
never arrived and the test deadlocked.

I think we are missing an ENSURE_ERROR_CLEANUP block there. See
attached patch with a testcase reproducing the issue.

A wakeup racing against a canceled waiter with no other live waiter
now errors with "could not find injection point ... to wake up"
instead of silently bumping the leaked slot.

I also attached a separate version for pg19, as master has a
refactored version of injection_wait. All previous branches have the
19 version, it should be easy to backport to other branches.

Attachment

pgsql-hackers by date:

Previous
From: Tofig Aliev
Date:
Subject: Re: Add cleanup parsing contexts for pg_hba and pg_ident files
Next
From: Andrey Borodin
Date:
Subject: Delete GIN posting tree pages without excessive locking