From 003aa7cd98a5c318ea5313ac6c8a3b3851b7377a Mon Sep 17 00:00:00 2001
From: Osumi Takamichi <osumi.takamichi@fujitsu.com>
Date: Mon, 14 Jun 2021 05:27:28 +0000
Subject: [PATCH v06] additional deadlock scenarios of synchronous logical decoding

Add (1) more scenario descriptions specific to logical decoding of two-phase transactions
to the exising deadlock list of synchronous logical decoding
and (2) a reference to this caveats from another section of two-phase commit.

Author: Takamichi Osumi <osumi.takamichi@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Vignesh C <vignesh21@gmail.com>
Discussion: https://www.postgresql.org/message-id/20210222222847.tpnb6eg3yiykzpky%40alap3.anarazel.de
---
 doc/src/sgml/logicaldecoding.sgml | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/doc/src/sgml/logicaldecoding.sgml b/doc/src/sgml/logicaldecoding.sgml
index d0fae5b..78eac27 100644
--- a/doc/src/sgml/logicaldecoding.sgml
+++ b/doc/src/sgml/logicaldecoding.sgml
@@ -1126,6 +1126,22 @@ OutputPluginWrite(ctx, true);
 
       <listitem>
        <para>
+        Performing <command>PREPARE TRANSACTION</command> after <command>LOCK</command>
+        command on <structname>pg_class</structname> and logical decoding of published
+        table.
+       </para>
+      </listitem>
+
+      <listitem>
+       <para>
+        Clustering <structname>pg_trigger</structname> and decoding <command>PREPARE
+        TRANSACTION</command>, if any published table have a trigger and any
+        operations that will be decoded are conducted.
+       </para>
+      </listitem>
+
+      <listitem>
+       <para>
         Executing <command>TRUNCATE</command> on user catalog table in a transaction.
        </para>
       </listitem>
@@ -1297,9 +1313,10 @@ stream_commit_cb(...);  &lt;-- commit of the streamed transaction
       <para>
        The logical replication solution that builds distributed two phase commit
        using this feature can deadlock if the prepared transaction has locked
-       [user] catalog tables exclusively. They need to inform users to not have
-       locks on catalog tables (via explicit <command>LOCK</command> command) in
-       such transactions.
+       [user] catalog tables exclusively. To avoid this users must refrain from
+       having locks on catalog tables (e.g. explicit <command>LOCK</command> command)
+       in such transactions.
+       (See <xref linkend="logicaldecoding-synchronous-caveats"/> for the details.)
       </para>
      </listitem>
     </itemizedlist>
-- 
2.2.0

