<structname>pg_stat_wal_receiver</structname></link> view. A large
difference between <function>pg_last_wal_replay_lsn</function> and the
view's <literal>flushed_lsn</literal> indicates that WAL is being
- received faster than it can be replayed.
+ received faster than it can be replayed. Recovery state and replay
+ progress can also be monitored via the
+ <link linkend="monitoring-pg-stat-recovery-view">
+ <structname>pg_stat_recovery</structname></link> view.
</para>
</sect3>
</sect2>
(In server versions before 14, the <varname>in_hot_standby</varname>
parameter did not exist; a workable substitute method for older servers
is <command>SHOW transaction_read_only</command>.) In addition, a set of
- functions (<xref linkend="functions-recovery-info-table"/>) allow users to
- access information about the standby server. These allow you to write
- programs that are aware of the current state of the database. These
+ functions (<xref linkend="functions-recovery-info-table"/>) and the
+ <link linkend="monitoring-pg-stat-recovery-view">
+ <structname>pg_stat_recovery</structname></link> view allow users to
+ access information about the standby server. These facilities allow you to
+ write programs that are aware of the current state of the database. They
can be used to monitor the progress of recovery, or to allow you to
write complex programs that restore the database to particular states.
</para>
<row>
<entry><structname>pg_stat_recovery</structname><indexterm><primary>pg_stat_recovery</primary></indexterm></entry>
- <entry>Only one row, showing statistics about the state of recovery.
+ <entry>At most one row, showing statistics about the recovery state.
See <link linkend="monitoring-pg-stat-recovery-view">
<structname>pg_stat_recovery</structname></link> for details.
</entry>
</indexterm>
<para>
- The <structname>pg_stat_recovery</structname> view will contain only
+ The <structname>pg_stat_recovery</structname> view will contain at most
one row, showing statistics about the recovery state of the startup
- process. This view returns no row when the server is not in recovery.
+ process. This view returns no rows when the server is not in recovery
+ or the user does not have privileges of the
+ <literal>pg_read_all_stats</literal> role.
</para>
<table id="pg-stat-recovery-view" xreflabel="pg_stat_recovery">
<structfield>last_replayed_end_lsn</structfield> <type>pg_lsn</type>
</para>
<para>
- End write-ahead log location of the last successfully replayed
- WAL record.
+ End write-ahead log location, plus one, of the last successfully
+ replayed WAL record.
</para></entry>
</row>
<structfield>replay_end_tli</structfield> <type>integer</type>
</para>
<para>
- Timeline of the WAL record currently being replayed.
+ Timeline of the WAL record currently being replayed. When no record
+ is being actively replayed, equals
+ <structfield>last_replayed_tli</structfield>.
</para></entry>
</row>
<row>
<entry role="catalog_table_entry"><para role="column_definition">
- <structfield>recovery_last_xact_time</structfield> <type>timestamp with time zone</type>
- </para>
- <para>
- Timestamp of the last transaction commit or abort replayed during
- recovery. This is the time at which the commit or abort WAL record
- for that transaction was generated on the primary.
+ <structfield>recovery_last_xact_time</structfield> <type>timestamp with time zone</type>
+ </para>
+ <para>
+ Timestamp of the last transaction commit or abort record replayed
+ during recovery. This is the time at which the commit or abort WAL
+ record for that transaction was generated on the primary.
</para></entry>
</row>
</para>
<para>
Time when the startup process observed that replay had caught up
- with the latest received WAL chunk. Used in recovery-conflict
- timing and replay/apply-lag diagnostics. NULL if not yet
+ with the latest WAL chunk received from streaming replication.
+ Used in recovery-conflict timing and replay/apply-lag diagnostics.
+ NULL if streaming WAL has not yet been received or the time is not
available.
</para></entry>
</row>