injection_points: canceled or terminated waiters leak their wait slots

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: injection_points: canceled or terminated waiters leak their wait slots
Date: 2026-07-21 08:28:22
Message-ID: CAN4CZFO+KF=cc0-iEg28RhqRBp_fTs6D4b8b7D7DB-pGYP3Ccg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
nocfbot-pg19-0001-injection_points-clear-waiter-slot-on-error-and-exit.patch application/octet-stream 9.2 KB
0001-injection_points-clear-waiter-slot-on-error-and-exit.patch application/octet-stream 8.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2026-07-21 08:30:52 Delete GIN posting tree pages without excessive locking
Previous Message Tofig Aliev 2026-07-21 08:19:27 Re: Add cleanup parsing contexts for pg_hba and pg_ident files