8000 Document a few caveats in synchronous logical replication. · postgres/postgres@ff33be6 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff33be6

Browse files
author
Amit Kapila
committed
Document a few caveats in synchronous logical replication.
In a synchronous logical setup, locking [user] catalog tables can cause deadlock. This is because logical decoding of transactions can lock catalog tables to access them so exclusively locking those in transactions can lead to deadlock. To avoid this users must refrain from having exclusive locks on catalog tables. Author: Takamichi Osumi Reviewed-by: Vignesh C, Amit Kapila Backpatch-through: 9.6 Discussion: https://www.postgresql.org/message-id/20210222222847.tpnb6eg3yiykzpky%40alap3.anarazel.de
1 parent feac82f commit ff33be6

File tree

1 file changed

+57
-19
lines changed

1 file changed

+57
-19
lines changed

doc/src/sgml/logicaldecoding.sgml

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -691,27 +691,65 @@ OutputPluginWrite(ctx, true);
691691

692692
<sect1 id="logicaldecoding-synchronous">
693693
<title>Synchronous Replication Support for Logical Decoding</title>
694+
<sect2>
695+
<title>Overview</title>
694696

695-
<para>
696-
Logical decoding can be used to build
697-
<link linkend="synchronous-replication">synchronous
698-
replication</link> solutions with the same user interface as synchronous
699-
replication for <link linkend="streaming-replication">streaming
700-
replication</link>. To do this, the streaming replication interface
701-
(see <xref linkend="logicaldecoding-walsender">) must be used to stream out
702-
data. Clients have to send <literal>Standby status update (F)</literal>
703-
(see <xref linkend="protocol-replication">) messages, just like streaming
704-
replication clients do.
705-
</para>
706-
707-
<note>
708697
<para>
709-
A synchronous replica receiving changes via logical decoding will work in
710-
the scope of a single database. Since, in contrast to
711-
that, <parameter>synchronous_standby_names</parameter> currently is
712-
server wide, this means this technique will not work properly if more
713-
than one database is actively used.
698+
Logical decoding can be used to build
699+
<link linkend="synchronous-replication">synchronous
700+
replication</link> solutions with the same user interface as synchronous
701+
replication for <link linkend="streaming-replication">streaming
702+
replication</link>. To do this, the streaming replication interface
703+
(see <xref linkend="logicaldecoding-walsender">) must be used to stream out
704+
data. Clients have to send <literal>Standby status update (F)</literal>
705+
(see <xref linkend="protocol-replication">) messages, just like streaming
706+
replication clients do.
707+
</para>
708+
709+
<note>
710+
<para>
711+
A synchronous replica receiving changes via logical decoding will work in
712+
the scope of a single database. Since, in contrast to
713+
that, <parameter>synchronous_standby_names</parameter> currently is
714+
server wide, this m 10000 eans this technique will not work properly if more
715+
than one database is actively used.
714716
</para>
715-
</note>
717+
</note>
718+
</sect2>
719+
720+
<sect2 id="logicaldecoding-synchronous-caveats">
721+
<title>Caveats</title>
722+
723+
<para>
724+
In synchronous replication setup, a deadlock can happen, if the transaction
725+
has locked [user] catalog tables exclusively. This is because logical decoding of
726+
transactions can lock catalog tables to access them. To avoid this users
727+
must refrain from taking an exclusive lock on [user] catalog tables. This can
728+
happen in the following ways:
729+
730+
<itemizedlist>
731+
<listitem>
732+
<para>
733+
Issuing an explicit <command>LOCK</command> on <structname>pg_class</structname>
734+
(or any other catalog table) in a transaction.
735+
</para>
736+
</listitem>
737+
738+
<listitem>
739+
<para>
740+
Perform <command>CLUSTER</command> on <structname>pg_class</structname> in a
741+
transaction.
742+
</para>
743+
</listitem>
744+
745+
<listitem>
746+
<para>
747+
Executing <command>TRUNCATE</command> on [user] catalog table in a
748+
transaction.
749+
</para>
750+
</listitem>
751+
</itemizedlist>
752+
</para>
753+
</sect2>
716754
</sect1>
717755
</chapter>

0 commit comments

Comments
 (0)
0