Rename two columns in pg_stat_subscription_stats.
authorAmit Kapila <[email protected]>
Tue, 18 Nov 2025 03:58:55 +0000 (03:58 +0000)
committerAmit Kapila <[email protected]>
Tue, 18 Nov 2025 03:58:55 +0000 (03:58 +0000)
This patch renames the sync_error_count column to sync_table_error_count
in the pg_stat_subscription_stats view. The new name makes the purpose
explicit now that a separate column exists to track sequence
synchronization errors.

Additionally, the column seq_sync_error_count is renamed to
sync_seq_error_count to maintain a consistent naming pattern, making it
easier for users to group, and query synchronization related counters.

Author: Vignesh C <[email protected]>
Reviewed-by: Peter Smith <[email protected]>
Reviewed-by: Chao Li <[email protected]>
Discussion: https://postgr.es/m/CALDaNm3WwJmz=-4ybTkhniB-Nf3qmFG9Zx1uKjyLLoPF5NYYXA@mail.gmail.com

doc/src/sgml/monitoring.sgml
src/backend/catalog/system_views.sql
src/backend/utils/activity/pgstat_subscription.c
src/backend/utils/adt/pgstatfuncs.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/include/pgstat.h
src/test/regress/expected/rules.out
src/test/subscription/t/026_stats.pl

index 7b9fa20df9e519f92a39ba4c5fa49e75b51cb1d0..436ef0e8bd06801e572e9459057e1cd2ec5a0d29 100644 (file)
@@ -2195,7 +2195,7 @@ description | Waiting for a newly initialized WAL file to reach durable storage
 
      <row>
       <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>seq_sync_error_count</structfield> <type>bigint</type>
+       <structfield>sync_seq_error_count</structfield> <type>bigint</type>
       </para>
       <para>
        Number of times an error occurred in the sequence synchronization
@@ -2206,7 +2206,7 @@ description | Waiting for a newly initialized WAL file to reach durable storage
 
      <row>
       <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>sync_error_count</structfield> <type>bigint</type>
+       <structfield>sync_table_error_count</structfield> <type>bigint</type>
       </para>
       <para>
        Number of times an error occurred during the initial table
index 059e8778ca7c79e563e7ed82005110f4476a4ae9..95ad29a64b987bfd89707264fdc45cbbd8d1fed3 100644 (file)
@@ -1415,8 +1415,8 @@ CREATE VIEW pg_stat_subscription_stats AS
         ss.subid,
         s.subname,
         ss.apply_error_count,
-        ss.seq_sync_error_count,
-        ss.sync_error_count,
+        ss.sync_seq_error_count,
+        ss.sync_table_error_count,
         ss.confl_insert_exists,
         ss.confl_update_origin_differs,
         ss.confl_update_exists,
index 35916772b9dc6d5612998220481a74b034b08046..ad6814ec5ea4424edf7d57d79a0925e3560f63b4 100644 (file)
@@ -41,11 +41,11 @@ pgstat_report_subscription_error(Oid subid, LogicalRepWorkerType wtype)
                        break;
 
                case WORKERTYPE_SEQUENCESYNC:
-                       pending->seq_sync_error_count++;
+                       pending->sync_seq_error_count++;
                        break;
 
                case WORKERTYPE_TABLESYNC:
-                       pending->sync_error_count++;
+                       pending->sync_table_error_count++;
                        break;
 
                default:
@@ -131,8 +131,8 @@ pgstat_subscription_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
 
 #define SUB_ACC(fld) shsubent->stats.fld += localent->fld
        SUB_ACC(apply_error_count);
-       SUB_ACC(seq_sync_error_count);
-       SUB_ACC(sync_error_count);
+       SUB_ACC(sync_seq_error_count);
+       SUB_ACC(sync_table_error_count);
        for (int i = 0; i < CONFLICT_NUM_TYPES; i++)
                SUB_ACC(conflict_count[i]);
 #undef SUB_ACC
index 1521d6e2ab43f4821f2fb3c364eecabaab335c78..3d98d064a94478edff2053aa5c2b610349747f41 100644 (file)
@@ -2221,9 +2221,9 @@ pg_stat_get_subscription_stats(PG_FUNCTION_ARGS)
                                           OIDOID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 2, "apply_error_count",
                                           INT8OID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 3, "seq_sync_error_count",
+       TupleDescInitEntry(tupdesc, (AttrNumber) 3, "sync_seq_error_count",
                                           INT8OID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 4, "sync_error_count",
+       TupleDescInitEntry(tupdesc, (AttrNumber) 4, "sync_table_error_count",
                                           INT8OID, -1, 0);
        TupleDescInitEntry(tupdesc, (AttrNumber) 5, "confl_insert_exists",
                                           INT8OID, -1, 0);
@@ -2258,11 +2258,11 @@ pg_stat_get_subscription_stats(PG_FUNCTION_ARGS)
        /* apply_error_count */
        values[i++] = Int64GetDatum(subentry->apply_error_count);
 
-       /* seq_sync_error_count */
-       values[i++] = Int64GetDatum(subentry->seq_sync_error_count);
+       /* sync_seq_error_count */
+       values[i++] = Int64GetDatum(subentry->sync_seq_error_count);
 
-       /* sync_error_count */
-       values[i++] = Int64GetDatum(subentry->sync_error_count);
+       /* sync_table_error_count */
+       values[i++] = Int64GetDatum(subentry->sync_table_error_count);
 
        /* conflict count */
        for (int nconflict = 0; nconflict < CONFLICT_NUM_TYPES; nconflict++)
index 7eefca1ae42922aa103ec173d409ad894ad5f53b..c061a2ec7dee4fb41b3835903287acf4a0ae7fcd 100644 (file)
@@ -57,6 +57,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     202511101
+#define CATALOG_VERSION_NO     202511181
 
 #endif
index 5cf9e12fcb9af7a4a28c14a3b39f06654ac3e614..aaadfd8c748e7098a0ae328ccec56ea7b0bfc657 100644 (file)
   proparallel => 'r', prorettype => 'record', proargtypes => 'oid',
   proallargtypes => '{oid,oid,int8,int8,int8,int8,int8,int8,int8,int8,int8,int8,int8,timestamptz}',
   proargmodes => '{i,o,o,o,o,o,o,o,o,o,o,o,o,o}',
-  proargnames => '{subid,subid,apply_error_count,seq_sync_error_count,sync_error_count,confl_insert_exists,confl_update_origin_differs,confl_update_exists,confl_update_deleted,confl_update_missing,confl_delete_origin_differs,confl_delete_missing,confl_multiple_unique_conflicts,stats_reset}',
+  proargnames => '{subid,subid,apply_error_count,sync_seq_error_count,sync_table_error_count,confl_insert_exists,confl_update_origin_differs,confl_update_exists,confl_update_deleted,confl_update_missing,confl_delete_origin_differs,confl_delete_missing,confl_multiple_unique_conflicts,stats_reset}',
   prosrc => 'pg_stat_get_subscription_stats' },
 { oid => '6118', descr => 'statistics: information about subscription',
   proname => 'pg_stat_get_subscription', prorows => '10', proisstrict => 'f',
index a0610bb3e3165426be682baa9060eb81da50c19e..a68e725259a22c7e592013a7258de241674aae7b 100644 (file)
@@ -109,8 +109,8 @@ typedef struct PgStat_FunctionCallUsage
 typedef struct PgStat_BackendSubEntry
 {
        PgStat_Counter apply_error_count;
-       PgStat_Counter seq_sync_error_count;
-       PgStat_Counter sync_error_count;
+       PgStat_Counter sync_seq_error_count;
+       PgStat_Counter sync_table_error_count;
        PgStat_Counter conflict_count[CONFLICT_NUM_TYPES];
 } PgStat_BackendSubEntry;
 
@@ -418,8 +418,8 @@ typedef struct PgStat_SLRUStats
 typedef struct PgStat_StatSubEntry
 {
        PgStat_Counter apply_error_count;
-       PgStat_Counter seq_sync_error_count;
-       PgStat_Counter sync_error_count;
+       PgStat_Counter sync_seq_error_count;
+       PgStat_Counter sync_table_error_count;
        PgStat_Counter conflict_count[CONFLICT_NUM_TYPES];
        TimestampTz stat_reset_timestamp;
 } PgStat_StatSubEntry;
index 7c52181cbcb3127cf2bc5817a30d149d2bd5af77..372a2188c22a43050606df893c2f5e76c1f6dcf2 100644 (file)
@@ -2191,8 +2191,8 @@ pg_stat_subscription| SELECT su.oid AS subid,
 pg_stat_subscription_stats| SELECT ss.subid,
     s.subname,
     ss.apply_error_count,
-    ss.seq_sync_error_count,
-    ss.sync_error_count,
+    ss.sync_seq_error_count,
+    ss.sync_table_error_count,
     ss.confl_insert_exists,
     ss.confl_update_origin_differs,
     ss.confl_update_exists,
@@ -2203,7 +2203,7 @@ pg_stat_subscription_stats| SELECT ss.subid,
     ss.confl_multiple_unique_conflicts,
     ss.stats_reset
    FROM pg_subscription s,
-    LATERAL pg_stat_get_subscription_stats(s.oid) ss(subid, apply_error_count, seq_sync_error_count, sync_error_count, confl_insert_exists, confl_update_origin_differs, confl_update_exists, confl_update_deleted, confl_update_missing, confl_delete_origin_differs, confl_delete_missing, confl_multiple_unique_conflicts, stats_reset);
+    LATERAL pg_stat_get_subscription_stats(s.oid) ss(subid, apply_error_count, sync_seq_error_count, sync_table_error_count, confl_insert_exists, confl_update_origin_differs, confl_update_exists, confl_update_deleted, confl_update_missing, confl_delete_origin_differs, confl_delete_missing, confl_multiple_unique_conflicts, stats_reset);
 pg_stat_sys_indexes| SELECT relid,
     indexrelid,
     schemaname,
index fc0bcee518736668f30109a73cbf2718f52be19d..a430ab4feeccad9cba04dfb37913a02154522e4a 100644 (file)
@@ -79,7 +79,7 @@ sub create_sub_pub_w_errors
                $db,
                qq[
        SELECT count(1) = 1 FROM pg_stat_subscription_stats
-       WHERE subname = '$sub_name' AND seq_sync_error_count > 0 AND sync_error_count > 0
+       WHERE subname = '$sub_name' AND sync_seq_error_count > 0 AND sync_table_error_count > 0
        ])
          or die
          qq(Timed out while waiting for sequencesync errors and tablesync errors for subscription '$sub_name');
@@ -175,8 +175,8 @@ my ($pub1_name, $sub1_name) =
 is( $node_subscriber->safe_psql(
                $db,
                qq(SELECT apply_error_count > 0,
-       seq_sync_error_count > 0,
-       sync_error_count > 0,
+       sync_seq_error_count > 0,
+       sync_table_error_count > 0,
        confl_insert_exists > 0,
        confl_delete_missing > 0,
        stats_reset IS NULL
@@ -197,8 +197,8 @@ $node_subscriber->safe_psql($db,
 is( $node_subscriber->safe_psql(
                $db,
                qq(SELECT apply_error_count = 0,
-       seq_sync_error_count = 0,
-       sync_error_count = 0,
+       sync_seq_error_count = 0,
+       sync_table_error_count = 0,
        confl_insert_exists = 0,
        confl_delete_missing = 0,
        stats_reset IS NOT NULL
@@ -242,8 +242,8 @@ my ($pub2_name, $sub2_name) =
 is( $node_subscriber->safe_psql(
                $db,
                qq(SELECT apply_error_count > 0,
-       seq_sync_error_count > 0,
-       sync_error_count > 0,
+       sync_seq_error_count > 0,
+       sync_table_error_count > 0,
        confl_insert_exists > 0,
        confl_delete_missing > 0,
        stats_reset IS NULL
@@ -263,8 +263,8 @@ $node_subscriber->safe_psql($db,
 is( $node_subscriber->safe_psql(
                $db,
                qq(SELECT apply_error_count = 0,
-       seq_sync_error_count = 0,
-       sync_error_count = 0,
+       sync_seq_error_count = 0,
+       sync_table_error_count = 0,
        confl_insert_exists = 0,
        confl_delete_missing = 0,
        stats_reset IS NOT NULL
@@ -278,8 +278,8 @@ is( $node_subscriber->safe_psql(
 is( $node_subscriber->safe_psql(
                $db,
                qq(SELECT apply_error_count = 0,
-       seq_sync_error_count = 0,
-       sync_error_count = 0,
+       sync_seq_error_count = 0,
+       sync_table_error_count = 0,
        confl_insert_exists = 0,
        confl_delete_missing = 0,
        stats_reset IS NOT NULL