| From: | Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix losing a sinval catchup signal that arrives during catchup |
| Date: | 2026-11-26 12:33:40 |
| Message-ID: | E1xWYfU-00000000OYd-0dCd@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix losing a sinval catchup signal that arrives during catchup
If a new catchup signal arrives while we're still processing a
previous catchup signal, the new signal might be lost:
When a backend falls far behind in the shared invalidation queue,
SICleanupQueue() sets its "signaled" flag, and sends it
PROCSIG_CATCHUP_INTERRUPT, which sets the catchupInterruptPending flag
in the receiving backend. There was a race condition in how
ReceiveSharedInvalidMessages() cleared catchupInterruptPending and
"signaled". It cleared "signaled" first, after consuming all the
messages, and catchupInterruptPending only after that. If a new
catchup signal arrived after the "signaled" flag was cleared in
SIGetDataEntries(), but before clearing catchupInterruptPending, the
backend could be left with its "signaled" flag set but
catchupInterruptPending not set. As a result, other backends would
not send it any more catchup signals, but it would not wake up to
consume the messages until AcceptInvalidationMessages() was called for
some other reason, typically when it next ran a query.
To fix, reset catchupInterruptPending only if "signaled" was not
concurrently re-armed. Move the responsibility for resetting it into
SICleanupQueue() itself, because it already holds the lock needed to
read "signaled".
No backpatching, since we have no reports from the field about this,
and the consequences are not that severe.
Reviewed-by: Shihao Zhong <zhong950419(at)gmail(dot)com>
Reviewed-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/42b2c4f9-511e-4b5c-8edd-b474019ddf29@iki.fi
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/3b249c728fd126c684be77ae834cb7eaa38d0962
Modified Files
--------------
src/backend/storage/ipc/sinval.c | 16 +++++++++-------
src/backend/storage/ipc/sinvaladt.c | 16 ++++++++++++++++
2 files changed, 25 insertions(+), 7 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Heikki Linnakangas | 2026-11-26 11:50:14 | pgsql: pg_upgrade: Don't run the not-null inheritance check on v18 clus |