Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7a85073

Browse files
author
Amit Kapila
committed
Reconsider pg_stat_subscription_workers view.
It was decided (refer to the Discussion link below) that the statscollector is not an appropriate place to store the error information ofsubscription workers.This patch changes the pg_stat_subscription_workers view (introduced bycommit8d74fc9) so that it stores only statistics counters:apply_error_count and sync_error_count, and has one entry foreach subscription. The removed error information such as error-XID andthe error message would be stored in another way in the future which ismore reliable and persistent.After removing these error details, there is no longer any relationinformation, so the subscription statistics are now a cluster-widestatistics.The patch also changes the view name to pg_stat_subscription_stats sincethe word "worker" is an implementation detail that we use one worker forone tablesync and one apply.Author: Masahiko Sawada, based on suggestions by Andres FreundReviewed-by: Peter Smith, Haiying Tang, Takamichi Osumi, Amit KapilaDiscussion:https://postgr.es/m/20220125063131.4cmvsxbz2tdg6g65@alap3.anarazel.de
1 parent54bd1e4 commit7a85073

File tree

14 files changed

+582
-864
lines changed

14 files changed

+582
-864
lines changed

‎doc/src/sgml/logical-replication.sgml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,7 @@
346346
<para>
347347
A conflict will produce an error and will stop the replication; it must be
348348
resolved manually by the user. Details about the conflict can be found in
349-
<link linkend="monitoring-pg-stat-subscription-workers">
350-
<structname>pg_stat_subscription_workers</structname></link> and the
351-
subscriber's server log.
349+
the subscriber's server log.
352350
</para>
353351

354352
<para>

‎doc/src/sgml/monitoring.sgml

Lines changed: 24 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
628628
</row>
629629

630630
<row>
631-
<entry><structname>pg_stat_subscription_workers</structname><indexterm><primary>pg_stat_subscription_workers</primary></indexterm></entry>
632-
<entry>One row per subscription worker, showing statistics about errors
633-
that occurred on that subscription worker.
634-
See <link linkend="monitoring-pg-stat-subscription-workers">
635-
<structname>pg_stat_subscription_workers</structname></link> for details.
631+
<entry><structname>pg_stat_subscription_stats</structname><indexterm><primary>pg_stat_subscription_stats</primary></indexterm></entry>
632+
<entry>One row per subscription, showing statistics about errors.
633+
See <link linkend="monitoring-pg-stat-subscription-stats">
634+
<structname>pg_stat_subscription_stats</structname></link> for details.
636635
</entry>
637636
</row>
638637

@@ -3063,23 +3062,20 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
30633062

30643063
</sect2>
30653064

3066-
<sect2 id="monitoring-pg-stat-subscription-workers">
3067-
<title><structname>pg_stat_subscription_workers</structname></title>
3065+
<sect2 id="monitoring-pg-stat-subscription-stats">
3066+
<title><structname>pg_stat_subscription_stats</structname></title>
30683067

30693068
<indexterm>
3070-
<primary>pg_stat_subscription_workers</primary>
3069+
<primary>pg_stat_subscription_stats</primary>
30713070
</indexterm>
30723071

30733072
<para>
3074-
The <structname>pg_stat_subscription_workers</structname> view will contain
3075-
one row per subscription worker on which errors have occurred, for workers
3076-
applying logical replication changes and workers handling the initial data
3077-
copy of the subscribed tables. The statistics entry is removed when the
3078-
corresponding subscription is dropped.
3073+
The <structname>pg_stat_subscription_stats</structname> view will contain
3074+
one row per subscription.
30793075
</para>
30803076

3081-
<table id="pg-stat-subscription-workers" xreflabel="pg_stat_subscription_workers">
3082-
<title><structname>pg_stat_subscription_workers</structname> View</title>
3077+
<table id="pg-stat-subscription-stats" xreflabel="pg_stat_subscription_stats">
3078+
<title><structname>pg_stat_subscription_stats</structname> View</title>
30833079
<tgroup cols="1">
30843080
<thead>
30853081
<row>
@@ -3113,72 +3109,31 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
31133109

31143110
<row>
31153111
<entry role="catalog_table_entry"><para role="column_definition">
3116-
<structfield>subrelid</structfield> <type>oid</type>
3112+
<structfield>apply_error_count</structfield> <type>bigint</type>
31173113
</para>
31183114
<para>
3119-
OID of the relation that the worker is synchronizing; null for the
3120-
main apply worker
3121-
</para></entry>
3122-
</row>
3123-
3124-
<row>
3125-
<entry role="catalog_table_entry"><para role="column_definition">
3126-
<structfield>last_error_relid</structfield> <type>oid</type>
3127-
</para>
3128-
<para>
3129-
OID of the relation that the worker was processing when the
3130-
error occurred
3115+
Number of times an error occurred while applying changes
31313116
</para></entry>
31323117
</row>
31333118

31343119
<row>
31353120
<entry role="catalog_table_entry"><para role="column_definition">
3136-
<structfield>last_error_command</structfield> <type>text</type>
3121+
<structfield>sync_error_count</structfield> <type>bigint</type>
31373122
</para>
31383123
<para>
3139-
Name ofcommand being applied when theerror occurred. This field
3140-
is null if the error was reported during the initial data copy.
3124+
Number oftimes anerror occurred during the initial table
3125+
synchronization
31413126
</para></entry>
31423127
</row>
31433128

31443129
<row>
31453130
<entry role="catalog_table_entry"><para role="column_definition">
3146-
<structfield>last_error_xid</structfield> <type>xid</type>
3147-
</para>
3148-
<para>
3149-
Transaction ID of the publisher node being applied when the error
3150-
occurred. This field is null if the error was reported
3151-
during the initial data copy.
3152-
</para></entry>
3153-
</row>
3154-
3155-
<row>
3156-
<entry role="catalog_table_entry"><para role="column_definition">
3157-
<structfield>last_error_count</structfield> <type>uint8</type>
3158-
</para>
3159-
<para>
3160-
Number of consecutive times the error occurred
3161-
</para></entry>
3162-
</row>
3163-
3164-
<row>
3165-
<entry role="catalog_table_entry"><para role="column_definition">
3166-
<structfield>last_error_message</structfield> <type>text</type>
3167-
</para>
3168-
<para>
3169-
The error message
3170-
</para></entry>
3171-
</row>
3172-
3173-
<row>
3174-
<entry role="catalog_table_entry"><para role="column_definition">
3175-
<structfield>last_error_time</structfield> <type>timestamp with time zone</type>
3131+
<structfield>stats_reset</structfield> <type>timestamp with time zone</type>
31763132
</para>
31773133
<para>
3178-
Last timeat whichthis error occurred
3134+
Timeat whichthese statistics were last reset
31793135
</para></entry>
31803136
</row>
3181-
31823137
</tbody>
31833138
</tgroup>
31843139
</table>
@@ -5320,22 +5275,16 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
53205275
<row>
53215276
<entry role="func_table_entry"><para role="func_signature">
53225277
<indexterm>
5323-
<primary>pg_stat_reset_subscription_worker</primary>
5278+
<primary>pg_stat_reset_subscription_stats</primary>
53245279
</indexterm>
5325-
<function>pg_stat_reset_subscription_worker</function> ( <parameter>subid</parameter> <type>oid</type> <optional>, <parameter>relid</parameter> <type>oid</type> </optional> )
5280+
<function>pg_stat_reset_subscription_stats</function> ( <type>oid</type> )
53265281
<returnvalue>void</returnvalue>
53275282
</para>
53285283
<para>
5329-
Resets the statistics of subscription workers running on the
5330-
subscription with <parameter>subid</parameter> shown in the
5331-
<structname>pg_stat_subscription_workers</structname> view. If the
5332-
argument <parameter>relid</parameter> is not <literal>NULL</literal>,
5333-
resets statistics of the subscription worker handling the initial data
5334-
copy of the relation with <parameter>relid</parameter>. Otherwise,
5335-
resets the subscription worker statistics of the main apply worker.
5336-
If the argument <parameter>relid</parameter> is omitted, resets the
5337-
statistics of all subscription workers running on the subscription
5338-
with <parameter>subid</parameter>.
5284+
Resets statistics for a single subscription shown in the
5285+
<structname>pg_stat_subscription_stats</structname> view to zero. If
5286+
the argument is <literal>NULL</literal>, reset statistics for all
5287+
subscriptions.
53395288
</para>
53405289
<para>
53415290
This function is restricted to superusers by default, but other users

‎src/backend/catalog/system_functions.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,7 @@ REVOKE EXECUTE ON FUNCTION pg_stat_reset_single_function_counters(oid) FROM publ
639639

640640
REVOKE EXECUTEON FUNCTION pg_stat_reset_replication_slot(text)FROM public;
641641

642-
REVOKE EXECUTEON FUNCTION pg_stat_reset_subscription_worker(oid)FROM public;
643-
644-
REVOKE EXECUTEON FUNCTION pg_stat_reset_subscription_worker(oid,oid)FROM public;
642+
REVOKE EXECUTEON FUNCTION pg_stat_reset_subscription_stats(oid)FROM public;
645643

646644
REVOKE EXECUTEON FUNCTION lo_import(text)FROM public;
647645

‎src/backend/catalog/system_views.sql

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,25 +1264,12 @@ GRANT SELECT (oid, subdbid, subname, subowner, subenabled, subbinary,
12641264
substream, subtwophasestate, subslotname, subsynccommit, subpublications)
12651265
ON pg_subscription TO public;
12661266

1267-
CREATEVIEWpg_stat_subscription_workersAS
1267+
CREATEVIEWpg_stat_subscription_statsAS
12681268
SELECT
1269-
w.subid,
1269+
ss.subid,
12701270
s.subname,
1271-
w.subrelid,
1272-
w.last_error_relid,
1273-
w.last_error_command,
1274-
w.last_error_xid,
1275-
w.last_error_count,
1276-
w.last_error_message,
1277-
w.last_error_time
1278-
FROM (SELECT
1279-
oidas subid,
1280-
NULLas relid
1281-
FROM pg_subscription
1282-
UNION ALL
1283-
SELECT
1284-
srsubidas subid,
1285-
srrelidas relid
1286-
FROM pg_subscription_rel) sr,
1287-
LATERAL pg_stat_get_subscription_worker(sr.subid,sr.relid) w
1288-
JOIN pg_subscription sON (w.subid=s.oid);
1271+
ss.apply_error_count,
1272+
ss.sync_error_count,
1273+
ss.stats_reset
1274+
FROM pg_subscriptionas s,
1275+
pg_stat_get_subscription_stats(s.oid)as ss;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp