Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 14d474e

Browse files
committed
Improve documentation for START_REPLICATION ... LOGICAL.
The starting point may not be exactly what the client requested; it may be at the slot's confirmed_flush_lsn. Also, upgrade the message from DEBUG1 to LOG when this happens. Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/c5c861d576f2511732f8002c76245da587110b1c.camel%40j-davis.com
1 parent 5fcf394 commit 14d474e

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

doc/src/sgml/protocol.sgml

+16-4
Original file line numberDiff line numberDiff line change
@@ -2410,10 +2410,22 @@ The commands accepted in replication mode are:
24102410
<term><literal>START_REPLICATION</literal> <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> <literal>LOGICAL</literal> <replaceable class="parameter">XXX/XXX</replaceable> [ ( <replaceable>option_name</replaceable> [ <replaceable>option_value</replaceable> ] [, ...] ) ]</term>
24112411
<listitem>
24122412
<para>
2413-
Instructs server to start streaming WAL for logical replication, starting
2414-
at WAL location <replaceable class="parameter">XXX/XXX</replaceable>. The server can
2415-
reply with an error, for example if the requested section of WAL has already
2416-
been recycled. On success, server responds with a CopyBothResponse
2413+
Instructs server to start streaming WAL for logical replication,
2414+
starting at either WAL location <replaceable
2415+
class="parameter">XXX/XXX</replaceable> or the slot's
2416+
<literal>confirmed_flush_lsn</literal> (see <xref
2417+
linkend="view-pg-replication-slots"/>), whichever is greater. This
2418+
behavior makes it easier for clients to avoid updating their local LSN
2419+
status when there is no data to process. However, starting at a
2420+
different LSN than requested might not catch certain kinds of client
2421+
errors; so the client may wish to check that
2422+
<literal>confirmed_flush_lsn</literal> matches its expectations before
2423+
issuing <literal>START_REPLICATION</literal>.
2424+
</para>
2425+
2426+
<para>
2427+
The server can reply with an error, for example if the
2428+
slot does not exist. On success, server responds with a CopyBothResponse
24172429
message, and then starts to stream WAL to the frontend.
24182430
</para>
24192431

src/backend/replication/logical/logical.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,12 @@ CreateDecodingContext(XLogRecPtr start_lsn,
520520
* xlog records didn't result in anything relevant for logical
521521
* decoding. Clients have to be able to do that to support synchronous
522522
* replication.
523+
*
524+
* Starting at a different LSN than requested might not catch certain
525+
* kinds of client errors; so the client may wish to check that
526+
* confirmed_flush_lsn matches its expectations.
523527
*/
524-
elog(DEBUG1, "cannot stream from %X/%X, minimum is %X/%X, forwarding",
528+
elog(LOG, "%X/%X has been already streamed, forwarding to %X/%X",
525529
LSN_FORMAT_ARGS(start_lsn),
526530
LSN_FORMAT_ARGS(slot->data.confirmed_flush));
527531

0 commit comments

Comments
 (0)