pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid waiting for a safe snapshot in notify-reading transactions
Date: Mon, 26 Oct 2026 17:02:06 +0000
Message-ID: <E1xLO5G-00000000rPU-0kog@gemulon.postgresql.org> (raw)

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@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.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(-)



Message-ID: <E1xLO5G-00000000rPU-0kog@gemulon.postgresql.org>
Permalink:  ../E1xLO5G-00000000rPU-0kog@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xLO5G-00000000rPU-0kog@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Avoid waiting for a safe snapshot in notify-reading transactions
  In-Reply-To: <E1xLO5G-00000000rPU-0kog@gemulon.postgresql.org>
  References: <E1xLO5G-00000000rPU-0kog@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox