]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/logicaldecoding-synchronous.html
WIP: toc builder
[ai-pg] / full-docs / src / sgml / html / logicaldecoding-synchronous.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>47.8. Synchronous Replication Support for Logical Decoding</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="logicaldecoding-writer.html" title="47.7. Logical Decoding Output Writers" /><link rel="next" href="logicaldecoding-streaming.html" title="47.9. Streaming of Large Transactions for Logical Decoding" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">47.8. Synchronous Replication Support for Logical Decoding</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="logicaldecoding-writer.html" title="47.7. Logical Decoding Output Writers">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="logicaldecoding.html" title="Chapter 47. Logical Decoding">Up</a></td><th width="60%" align="center">Chapter 47. Logical Decoding</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="logicaldecoding-streaming.html" title="47.9. Streaming of Large Transactions for Logical Decoding">Next</a></td></tr></table><hr /></div><div class="sect1" id="LOGICALDECODING-SYNCHRONOUS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">47.8. Synchronous Replication Support for Logical Decoding <a href="#LOGICALDECODING-SYNCHRONOUS" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="logicaldecoding-synchronous.html#LOGICALDECODING-SYNCHRONOUS-OVERVIEW">47.8.1. Overview</a></span></dt><dt><span class="sect2"><a href="logicaldecoding-synchronous.html#LOGICALDECODING-SYNCHRONOUS-CAVEATS">47.8.2. Caveats</a></span></dt></dl></div><div class="sect2" id="LOGICALDECODING-SYNCHRONOUS-OVERVIEW"><div class="titlepage"><div><div><h3 class="title">47.8.1. Overview <a href="#LOGICALDECODING-SYNCHRONOUS-OVERVIEW" class="id_link">#</a></h3></div></div></div><p>
3      Logical decoding can be used to build
4      <a class="link" href="warm-standby.html#SYNCHRONOUS-REPLICATION" title="26.2.8. Synchronous Replication">synchronous
5      replication</a> solutions with the same user interface as synchronous
6      replication for <a class="link" href="warm-standby.html#STREAMING-REPLICATION" title="26.2.5. Streaming Replication">streaming
7      replication</a>.  To do this, the streaming replication interface
8      (see <a class="xref" href="logicaldecoding-walsender.html" title="47.3. Streaming Replication Protocol Interface">Section 47.3</a>) must be used to stream out
9      data. Clients have to send <code class="literal">Standby status update (F)</code>
10      (see <a class="xref" href="protocol-replication.html" title="54.4. Streaming Replication Protocol">Section 54.4</a>) messages, just like streaming
11      replication clients do.
12     </p><div class="note"><h3 class="title">Note</h3><p>
13       A synchronous replica receiving changes via logical decoding will work in
14       the scope of a single database. Since, in contrast to
15       that, <em class="parameter"><code>synchronous_standby_names</code></em> currently is
16       server wide, this means this technique will not work properly if more
17       than one database is actively used.
18      </p></div></div><div class="sect2" id="LOGICALDECODING-SYNCHRONOUS-CAVEATS"><div class="titlepage"><div><div><h3 class="title">47.8.2. Caveats <a href="#LOGICALDECODING-SYNCHRONOUS-CAVEATS" class="id_link">#</a></h3></div></div></div><p>
19      In synchronous replication setup, a deadlock can happen, if the transaction
20      has locked [user] catalog tables exclusively. See
21      <a class="xref" href="logicaldecoding-output-plugin.html#LOGICALDECODING-CAPABILITIES" title="47.6.2. Capabilities">Section 47.6.2</a> for information on user
22      catalog tables. This is because logical decoding of transactions can lock
23      catalog tables to access them. To avoid this users must refrain from taking
24      an exclusive lock on [user] catalog tables. This can happen in the following
25      ways:
26
27      </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
28         Issuing an explicit <code class="command">LOCK</code> on <code class="structname">pg_class</code>
29         in a transaction.
30        </p></li><li class="listitem"><p>
31         Perform <code class="command">CLUSTER</code> on <code class="structname">pg_class</code> in
32         a transaction.
33        </p></li><li class="listitem"><p>
34         <code class="command">PREPARE TRANSACTION</code> after <code class="command">LOCK</code> command
35         on <code class="structname">pg_class</code> and allow logical decoding of two-phase
36         transactions.
37        </p></li><li class="listitem"><p>
38         <code class="command">PREPARE TRANSACTION</code> after <code class="command">CLUSTER</code>
39         command on <code class="structname">pg_trigger</code> and allow logical decoding of
40         two-phase transactions. This will lead to deadlock only when published table
41         have a trigger.
42        </p></li><li class="listitem"><p>
43         Executing <code class="command">TRUNCATE</code> on [user] catalog table in a
44         transaction.
45        </p></li></ul></div><p>
46
47      Note that these commands can cause deadlocks not only for the system
48      catalog tables listed above but for other catalog tables.
49     </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="logicaldecoding-writer.html" title="47.7. Logical Decoding Output Writers">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="logicaldecoding.html" title="Chapter 47. Logical Decoding">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="logicaldecoding-streaming.html" title="47.9. Streaming of Large Transactions for Logical Decoding">Next</a></td></tr><tr><td width="40%" align="left" valign="top">47.7. Logical Decoding Output Writers </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 47.9. Streaming of Large Transactions for Logical Decoding</td></tr></table></div></body></html>