|
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <!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>52.5. Logical Streaming Replication Protocol</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 V1.79.1" /><link rel="prev" href="protocol-replication.html" title="52.4. Streaming Replication Protocol" /><link rel="next" href="protocol-message-types.html" title="52.6. Message Data Types" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">52.5. Logical Streaming Replication Protocol</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="protocol-replication.html" title="52.4. Streaming Replication Protocol">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="protocol.html" title="Chapter 52. Frontend/Backend Protocol">Up</a></td><th width="60%" align="center">Chapter 52. Frontend/Backend Protocol</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="protocol-message-types.html" title="52.6. Message Data Types">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="PROTOCOL-LOGICAL-REPLICATION"><div class="titlepage"><div><div><h2 class="title" style="clear: both">52.5. Logical Streaming Replication Protocol</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="protocol-logical-replication.html#PROTOCOL-LOGICAL-REPLICATION-PARAMS">52.5.1. Logical Streaming Replication Parameters</a></span></dt><dt><span class="sect2"><a href="protocol-logical-replication.html#PROTOCOL-LOGICAL-MESSAGES">52.5.2. Logical Replication Protocol Messages</a></span></dt><dt><span class="sect2"><a href="protocol-logical-replication.html#PROTOCOL-LOGICAL-MESSAGES-FLOW">52.5.3. Logical Replication Protocol Message Flow</a></span></dt></dl></div><p>
- This section describes the logical replication protocol, which is the message
- flow started by the <code class="literal">START_REPLICATION</code>
- <code class="literal">SLOT</code> <em class="replaceable"><code>slot_name</code></em>
- <code class="literal">LOGICAL</code> replication command.
- </p><p>
- The logical streaming replication protocol builds on the primitives of
- the physical streaming replication protocol.
- </p><div class="sect2" id="PROTOCOL-LOGICAL-REPLICATION-PARAMS"><div class="titlepage"><div><div><h3 class="title">52.5.1. Logical Streaming Replication Parameters</h3></div></div></div><p>
- The logical replication <code class="literal">START_REPLICATION</code> command
- accepts following parameters:
-
- </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
- proto_version
- </span></dt><dd><p>
- Protocol version. Currently only version <code class="literal">1</code> is
- supported.
- </p></dd><dt><span class="term">
- publication_names
- </span></dt><dd><p>
- Comma separated list of publication names for which to subscribe
- (receive changes). The individual publication names are treated
- as standard objects names and can be quoted the same as needed.
- </p></dd></dl></div><p>
-
- </p></div><div class="sect2" id="PROTOCOL-LOGICAL-MESSAGES"><div class="titlepage"><div><div><h3 class="title">52.5.2. Logical Replication Protocol Messages</h3></div></div></div><p>
- The individual protocol messages are discussed in the following
- subsections. Individual messages are described in
- <a class="xref" href="protocol-logicalrep-message-formats.html" title="52.9. Logical Replication Message Formats">Section 52.9</a>.
- </p><p>
- All top-level protocol messages begin with a message type byte.
- While represented in code as a character, this is a signed byte with no
- associated encoding.
- </p><p>
- Since the streaming replication protocol supplies a message length there
- is no need for top-level protocol messages to embed a length in their
- header.
- </p></div><div class="sect2" id="PROTOCOL-LOGICAL-MESSAGES-FLOW"><div class="titlepage"><div><div><h3 class="title">52.5.3. Logical Replication Protocol Message Flow</h3></div></div></div><p>
- With the exception of the <code class="literal">START_REPLICATION</code> command and
- the replay progress messages, all information flows only from the backend
- to the frontend.
- </p><p>
- The logical replication protocol sends individual transactions one by one.
- This means that all messages between a pair of Begin and Commit messages
- belong to the same transaction.
- </p><p>
- Every sent transaction contains zero or more DML messages (Insert,
- Update, Delete). In case of a cascaded setup it can also contain Origin
- messages. The origin message indicated that the transaction originated on
- different replication node. Since a replication node in the scope of logical
- replication protocol can be pretty much anything, the only identifier
- is the origin name. It's downstream's responsibility to handle this as
- needed (if needed). The Origin message is always sent before any DML
- messages in the transaction.
- </p><p>
- Every DML message contains an arbitrary relation ID, which can be mapped to
- an ID in the Relation messages. The Relation messages describe the schema of the
- given relation. The Relation message is sent for a given relation either
- because it is the first time we send a DML message for given relation in the
- current session or because the relation definition has changed since the
- last Relation message was sent for it. The protocol assumes that the client
- is capable of caching the metadata for as many relations as needed.
- </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="protocol-replication.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="protocol.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="protocol-message-types.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">52.4. Streaming Replication Protocol </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 52.6. Message Data Types</td></tr></table></div></body></html>
|