pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Doc: Explain prepared transaction lock waits with two_phase subs
Date: Wed, 18 Nov 2026 05:19:44 +0000
Message-ID: <E1xTY59-00000000CAN-3kjB@gemulon.postgresql.org> (raw)

Doc: Explain prepared transaction lock waits with two_phase subscriptions.

A transaction prepared by the apply worker retains its locks until the
corresponding COMMIT PREPARED or ROLLBACK PREPARED is applied. If another
session waits for a conflicting lock held by the prepared transaction, the
apply worker's subsequent conflicting lock requests can queue behind that
session. This can prevent the apply worker from reaching the
COMMIT PREPARED or ROLLBACK PREPARED that would release the prepared
transaction's locks.

The deadlock detector cannot detect this situation because a prepared
transaction does not wait for any locks and therefore cannot participate
in a deadlock cycle. As a result, replication can remain stalled
indefinitely.

Document this behavior and the recovery procedure under
CREATE SUBSCRIPTION and PREPARE TRANSACTION.

Author: Zhijie Hou <houzhijie22@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/72c9b956-96c3-40a5-99bb-d9b7338c0bab@gmail.com
Backpatch-through: 15

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f03a0f879631d2e310f01d9bf0016d5298f4dbe0

Modified Files
--------------
doc/src/sgml/ref/create_subscription.sgml | 22 ++++++++++++++++++++++
doc/src/sgml/ref/prepare_transaction.sgml |  6 +++++-
2 files changed, 27 insertions(+), 1 deletion(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1xTY59-00000000CAN-3kjB@gemulon.postgresql.org>
Permalink:  ../E1xTY59-00000000CAN-3kjB@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xTY59-00000000CAN-3kjB@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: akapila@postgresql.org
  Subject: Re: pgsql: Doc: Explain prepared transaction lock waits with two_phase subs
  In-Reply-To: <E1xTY59-00000000CAN-3kjB@gemulon.postgresql.org>
  References: <E1xTY59-00000000CAN-3kjB@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