From 68ed56a86b0da17cadfddd939c8e2430b59c4f53 Mon Sep 17 00:00:00 2001
From: Ronan Dunklau <ronan.dunklau@aiven.io>
Date: Mon, 6 Sep 2021 11:08:54 +0200
Subject: [PATCH v6 3/3] Add documentation for pg_receivewal

---
 doc/src/sgml/ref/pg_receivewal.sgml | 33 +++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/doc/src/sgml/ref/pg_receivewal.sgml b/doc/src/sgml/ref/pg_receivewal.sgml
index 45b544cf49..46e141bc21 100644
--- a/doc/src/sgml/ref/pg_receivewal.sgml
+++ b/doc/src/sgml/ref/pg_receivewal.sgml
@@ -37,6 +37,34 @@ PostgreSQL documentation
    <xref linkend="continuous-archiving"/>).
   </para>
 
+  <para>
+    When <application>pg_receivewal</application> is launched, it tries to determine the
+    starting LSN from the following sources:
+    <orderedlist>
+      <listitem>
+      <para>
+      The target directory is scanned to determine what is the next file we
+      should archive.
+      </para>
+      </listitem>
+
+      <listitem>
+      <para>
+      If nothing is found and a slot is specified, use the
+      <command>READ_REPLICATION_SLOT</command>
+      command.
+      </para>
+      </listitem>
+
+      <listitem>
+      <para>
+      If we still don't have a valid start position, use the last flush
+      location as reported by the server.
+      </para>
+      </listitem>
+    </orderedlist>
+  </para>
+
   <para>
    <application>pg_receivewal</application> streams the write-ahead
    log in real time as it's being generated on the server, and does not wait
@@ -198,6 +226,11 @@ PostgreSQL documentation
          satisfactorily.  The option <literal>--synchronous</literal> (see
          below) must be specified in addition to make this work correctly.
         </para>
+
+        <para>
+        The slot's <literal>restart_lsn</literal> can also be used as a starting
+        point if the target directory is empty.
+        </para>
       </listitem>
      </varlistentry>
 
-- 
2.33.0

