@@ -28989,12 +28989,15 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
28989
28989
</para>
28990
28990
28991
28991
<table id="recovery-synchronization-procedure-table">
28992
- <title>Recovery Synchronization Procedure</title>
28992
+ <title>Recovery Synchronization Procedure and Function </title>
28993
28993
<tgroup cols="1">
28994
28994
<thead>
28995
28995
<row>
28996
28996
<entry role="func_table_entry"><para role="func_signature">
28997
- Procedure
28997
+ Procedure or Function
28998
+ </para>
28999
+ <para>
29000
+ Type
28998
29001
</para>
28999
29002
<para>
29000
29003
Description
@@ -29010,8 +29013,11 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
29010
29013
</indexterm>
29011
29014
<function>pg_wal_replay_wait</function> (
29012
29015
<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
29015
29021
</para>
29016
29022
<para>
29017
29023
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
29022
29028
procedure waits until <literal>target_lsn</literal> is reached or
29023
29029
the specified <parameter>timeout</parameter> has elapsed.
29024
29030
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>.
29026
29055
</para></entry>
29027
29056
</row>
29028
29057
</tbody>
@@ -29044,7 +29073,8 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
29044
29073
<para>
29045
29074
<function>pg_wal_replay_wait</function> should be called on standby.
29046
29075
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
29048
29078
called on primary promoted from standby and <literal>target_lsn</literal>
29049
29079
was already replayed, then <function>pg_wal_replay_wait</function> just
29050
29080
exits immediately.
@@ -29090,6 +29120,20 @@ postgres=# CALL pg_wal_replay_wait('0/306EE20', 100);
29090
29120
ERROR: timed out while waiting for target LSN 0/306EE20 to be replayed; current replay LSN 0/306EA60
29091
29121
</programlisting>
29092
29122
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
+
29093
29137
</para>
29094
29138
29095
29139
<para>
0 commit comments