From 845b2fdd33318f0d7528ef0ecbb69e4aecf43c46 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 v7 3/3] Add documentation for pg_receivewal

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

diff --git a/doc/src/sgml/ref/pg_receivewal.sgml b/doc/src/sgml/ref/pg_receivewal.sgml
index 45b544cf49..5fb2b61d34 100644
--- a/doc/src/sgml/ref/pg_receivewal.sgml
+++ b/doc/src/sgml/ref/pg_receivewal.sgml
@@ -37,6 +37,32 @@ 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>
+      It scans the target directory to determine the next file it should archive.
+      </para>
+      </listitem>
+
+      <listitem>
+      <para>
+      If it doesn't find that file, and a slot was specified, it uses the
+      <command>READ_REPLICATION_SLOT</command> command to retrieve the slot's <literal>restart_lsn</literal>
+      </para>
+      </listitem>
+
+      <listitem>
+      <para>
+      If it still don't find a valid start position via <command>READ_REPLICATION_SLOT</command>,
+      it uses 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
-- 
2.33.0

