pgsql: Avoid waiting for a safe snapshot in notify-reading transactions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid waiting for a safe snapshot in notify-reading transactions
Date: 2026-10-26 17:02:06
Message-ID: E1xLO5G-00000000rPU-0kog@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid waiting for a safe snapshot in notify-reading transactions.

In the perhaps-unlikely scenario where your session default settings
specify read-only, deferrable, serializable transactions, the implicit
transaction created by ProcessIncomingNotify() honored those settings
and would wait for a safe snapshot to be creatable; thereby getting
blocked by any long-running concurrent transaction. This is a bit
surprising, especially if you think you are committing a transaction
that doesn't have those properties.

There doesn't seem to be any good semantic reason for NOTIFY reporting
to wait for a safe snapshot, so create a code pathway that lets it
just get a plain snapshot, independently of transaction mode.

Given the lack of field complaints about such issues, I don't feel a
need to back-patch this.

Author: shihao zhong <zhong950419(at)gmail(dot)com>
Co-authored-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAGRkXqQ1bmVwBw2CXiyZeWWP=XkHPXLPcQ7BSg2Q5JKSvDAnTA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6e9e5681b8a7ff3c5eea09db980e888c8e81ad9c

Modified Files
--------------
src/backend/commands/async.c | 7 ++++++-
src/backend/utils/time/snapmgr.c | 30 ++++++++++++++++++++++++++++++
src/include/utils/snapmgr.h | 1 +
3 files changed, 37 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Manu 2026-10-26 17:40:53 Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Previous Message Daniel Gustafsson 2026-10-26 14:20:57 pgsql: Fix pg_basebackup long-path test on Windows