mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Add a view to show the stats of subscription workers.
This commit adds a new system view pg_stat_subscription_workers, that shows information about any errors which occur during the application of logical replication changes as well as during performing initial table synchronization. The subscription statistics entries are removed when the corresponding subscription is removed. It also adds an SQL function pg_stat_reset_subscription_worker() to reset single subscription errors. The contents of this view can be used by an upcoming patch that skips the particular transaction that conflicts with the existing data on the subscriber. This view can be extended in the future to track other xact related statistics like the number of xacts committed/aborted for subscription workers. Author: Masahiko Sawada Reviewed-by: Greg Nancarrow, Hou Zhijie, Tang Haiying, Vignesh C, Dilip Kumar, Takamichi Osumi, Amit Kapila Discussion: https://postgr.es/m/CAD21AoDeScrsHhLyEPYqN3sydg6PxAPVBboK=30xJfUVihNZDA@mail.gmail.com
This commit is contained in:
@ -627,6 +627,15 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><structname>pg_stat_subscription_workers</structname><indexterm><primary>pg_stat_subscription_workers</primary></indexterm></entry>
|
||||
<entry>One row per subscription worker, showing statistics about errors
|
||||
that occurred on that subscription worker.
|
||||
See <link linkend="monitoring-pg-stat-subscription-workers">
|
||||
<structname>pg_stat_subscription_workers</structname></link> for details.
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
@ -3054,6 +3063,128 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="monitoring-pg-stat-subscription-workers">
|
||||
<title><structname>pg_stat_subscription_workers</structname></title>
|
||||
|
||||
<indexterm>
|
||||
<primary>pg_stat_subscription_workers</primary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
The <structname>pg_stat_subscription_workers</structname> view will contain
|
||||
one row per subscription worker on which errors have occurred, for workers
|
||||
applying logical replication changes and workers handling the initial data
|
||||
copy of the subscribed tables. The statistics entry is removed when the
|
||||
corresponding subscription is dropped.
|
||||
</para>
|
||||
|
||||
<table id="pg-stat-subscription-workers" xreflabel="pg_stat_subscription_workers">
|
||||
<title><structname>pg_stat_subscription_workers</structname> View</title>
|
||||
<tgroup cols="1">
|
||||
<thead>
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
Column Type
|
||||
</para>
|
||||
<para>
|
||||
Description
|
||||
</para></entry>
|
||||
</row>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>subid</structfield> <type>oid</type>
|
||||
</para>
|
||||
<para>
|
||||
OID of the subscription
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>subname</structfield> <type>name</type>
|
||||
</para>
|
||||
<para>
|
||||
Name of the subscription
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>subrelid</structfield> <type>oid</type>
|
||||
</para>
|
||||
<para>
|
||||
OID of the relation that the worker is synchronizing; null for the
|
||||
main apply worker
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>last_error_relid</structfield> <type>oid</type>
|
||||
</para>
|
||||
<para>
|
||||
OID of the relation that the worker was processing when the
|
||||
error occurred
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>last_error_command</structfield> <type>text</type>
|
||||
</para>
|
||||
<para>
|
||||
Name of command being applied when the error occurred. This field
|
||||
is null if the error was reported during the initial data copy.
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>last_error_xid</structfield> <type>xid</type>
|
||||
</para>
|
||||
<para>
|
||||
Transaction ID of the publisher node being applied when the error
|
||||
occurred. This field is null if the error was reported
|
||||
during the initial data copy.
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>last_error_count</structfield> <type>uint8</type>
|
||||
</para>
|
||||
<para>
|
||||
Number of consecutive times the error occurred
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>last_error_message</structfield> <type>text</type>
|
||||
</para>
|
||||
<para>
|
||||
The error message
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>last_error_time</structfield> <type>timestamp with time zone</type>
|
||||
</para>
|
||||
<para>
|
||||
Last time at which this error occurred
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="monitoring-pg-stat-ssl-view">
|
||||
<title><structname>pg_stat_ssl</structname></title>
|
||||
|
||||
@ -5176,6 +5307,32 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
||||
can be granted EXECUTE to run the function.
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
<primary>pg_stat_reset_subscription_worker</primary>
|
||||
</indexterm>
|
||||
<function>pg_stat_reset_subscription_worker</function> ( <parameter>subid</parameter> <type>oid</type> <optional>, <parameter>relid</parameter> <type>oid</type> </optional> )
|
||||
<returnvalue>void</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Resets the statistics of subscription workers running on the
|
||||
subscription with <parameter>subid</parameter> shown in the
|
||||
<structname>pg_stat_subscription_workers</structname> view. If the
|
||||
argument <parameter>relid</parameter> is not <literal>NULL</literal>,
|
||||
resets statistics of the subscription worker handling the initial data
|
||||
copy of the relation with <parameter>relid</parameter>. Otherwise,
|
||||
resets the subscription worker statistics of the main apply worker.
|
||||
If the argument <parameter>relid</parameter> is omitted, resets the
|
||||
statistics of all subscription workers running on the subscription
|
||||
with <parameter>subid</parameter>.
|
||||
</para>
|
||||
<para>
|
||||
This function is restricted to superusers by default, but other users
|
||||
can be granted EXECUTE to run the function.
|
||||
</para></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
Reference in New Issue
Block a user