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

Started by Tom Lane27 days ago1 messagescommitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

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: /messages/by-id/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(-)