@@ -28989,12 +28989,15 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
2898928989 </para>
2899028990
2899128991 <table id="recovery-synchronization-procedure-table">
28992- <title>Recovery Synchronization Procedure</title>
28992+ <title>Recovery Synchronization Procedure and Function </title>
2899328993 <tgroup cols="1">
2899428994 <thead>
2899528995 <row>
2899628996 <entry role="func_table_entry"><para role="func_signature">
28997- Procedure
28997+ Procedure or Function
28998+ </para>
28999+ <para>
29000+ Type
2899829001 </para>
2899929002 <para>
2900029003 Description
@@ -29010,8 +29013,11 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
2901029013 </indexterm>
2901129014 <function>pg_wal_replay_wait</function> (
2901229015 <parameter>target_lsn</parameter> <type>pg_lsn</type>,
29013- <parameter>timeout</parameter> <type>bigint</type> <literal>DEFAULT</literal> <literal>0</literal>)
29014- <returnvalue>void</returnvalue>
29016+ <parameter>timeout</parameter> <type>bigint</type> <literal>DEFAULT</literal> <literal>0</literal>,
29017+ <parameter>no_error</parameter> <type>bool</type> <literal>DEFAULT</literal> <literal>false</literal>)
29018+ </para>
29019+ <para>
29020+ Procedure
2901529021 </para>
2901629022 <para>
2901729023 Waits until recovery replays <literal>target_lsn</literal>.
@@ -29022,7 +29028,30 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
2902229028 procedure waits until <literal>target_lsn</literal> is reached or
2902329029 the specified <parameter>timeout</parameter> has elapsed.
2902429030 On timeout, or if the server is promoted before
29025- <literal>target_lsn</literal> is reached, an error is emitted.
29031+ <literal>target_lsn</literal> is reached, an error is emitted,
29032+ as soon as <parameter>no_error</parameter> is false.
29033+ If <parameter>no_error</parameter> is set to true, then the procedure
29034+ doesn't throw errors. The last result status could be read
29035+ with <function>pg_wal_replay_wait_status</function>.
29036+ </para></entry>
29037+ </row>
29038+
29039+ <row>
29040+ <entry role="func_table_entry"><para role="func_signature">
29041+ <indexterm>
29042+ <primary>pg_wal_replay_wait_status</primary>
29043+ </indexterm>
29044+ <function>pg_wal_replay_wait_status</function> ()
29045+ <returnvalue>text</returnvalue>
29046+ </para>
29047+ <para>
29048+ Function
29049+ </para>
29050+ <para>
29051+ Returns the last result status for
29052+ <function>pg_wal_replay_wait</function> procedure. The possible
29053+ values are <literal>success</literal>, <literal>timeout</literal>,
29054+ and <literal>not in recovery</literal>.
2902629055 </para></entry>
2902729056 </row>
2902829057 </tbody>
@@ -29044,7 +29073,8 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
2904429073 <para>
2904529074 <function>pg_wal_replay_wait</function> should be called on standby.
2904629075 If a user calls <function>pg_wal_replay_wait</function> on primary, it
29047- will error out. However, if <function>pg_wal_replay_wait</function> is
29076+ will error out as soon as <parameter>no_error</parameter> is false.
29077+ However, if <function>pg_wal_replay_wait</function> is
2904829078 called on primary promoted from standby and <literal>target_lsn</literal>
2904929079 was already replayed, then <function>pg_wal_replay_wait</function> just
2905029080 exits immediately.
@@ -29090,6 +29120,20 @@ postgres=# CALL pg_wal_replay_wait('0/306EE20', 100);
2909029120ERROR: timed out while waiting for target LSN 0/306EE20 to be replayed; current replay LSN 0/306EA60
2909129121 </programlisting>
2909229122
29123+ The same example uses <function>pg_wal_replay_wait</function> with
29124+ <parameter>no_error</parameter> set to true. In this case, the result
29125+ status must be read with <function>pg_wal_replay_wait_status</function>.
29126+
29127+ <programlisting>
29128+ postgres=# CALL pg_wal_replay_wait('0/306EE20', 100, true);
29129+ CALL
29130+ postgres=# SELECT pg_wal_replay_wait_status();
29131+ pg_wal_replay_wait_status
29132+ ---------------------------
29133+ timeout
29134+ (1 row)
29135+ </programlisting>
29136+
2909329137 </para>
2909429138
2909529139 <para>
0 commit comments