From 951f28e51443fc33f95dd8ddae68d90514641148 Mon Sep 17 00:00:00 2001 From: Vignesh C Date: Tue, 11 Nov 2025 19:55:21 +0530 Subject: [PATCH] Rename sync_error_count to tbl_sync_error_count in subscription statistics Rename the sync_error_count column to tbl_sync_error_count in pg_stat_subscription_stats view. This change makes the naming more explicit, as a new column seq_sync_error_count has been added to track sequence synchronization errors separately. The renaming helps avoid confusion between table sync and sequence sync error counts. --- doc/src/sgml/monitoring.sgml | 2 +- src/backend/catalog/system_views.sql | 2 +- src/backend/utils/activity/pgstat_subscription.c | 4 ++-- src/backend/utils/adt/pgstatfuncs.c | 6 +++--- src/include/catalog/pg_proc.dat | 2 +- src/include/pgstat.h | 4 ++-- src/test/regress/expected/rules.out | 4 ++-- src/test/subscription/t/026_stats.pl | 12 ++++++------ 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 2741c138593..88636e705ab 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -2205,7 +2205,7 @@ description | Waiting for a newly initialized WAL file to reach durable storage - sync_error_count bigint + tbl_sync_error_count bigint Number of times an error occurred during the initial table diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 059e8778ca7..fa540801959 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -1416,7 +1416,7 @@ CREATE VIEW pg_stat_subscription_stats AS s.subname, ss.apply_error_count, ss.seq_sync_error_count, - ss.sync_error_count, + ss.tbl_sync_error_count, ss.confl_insert_exists, ss.confl_update_origin_differs, ss.confl_update_exists, diff --git a/src/backend/utils/activity/pgstat_subscription.c b/src/backend/utils/activity/pgstat_subscription.c index 35916772b9d..f74f221ca10 100644 --- a/src/backend/utils/activity/pgstat_subscription.c +++ b/src/backend/utils/activity/pgstat_subscription.c @@ -45,7 +45,7 @@ pgstat_report_subscription_error(Oid subid, LogicalRepWorkerType wtype) break; case WORKERTYPE_TABLESYNC: - pending->sync_error_count++; + pending->tbl_sync_error_count++; break; default: @@ -132,7 +132,7 @@ 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(tbl_sync_error_count); for (int i = 0; i < CONFLICT_NUM_TYPES; i++) SUB_ACC(conflict_count[i]); #undef SUB_ACC diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 1521d6e2ab4..44bb06154c9 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -2223,7 +2223,7 @@ pg_stat_get_subscription_stats(PG_FUNCTION_ARGS) INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 3, "seq_sync_error_count", INT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 4, "sync_error_count", + TupleDescInitEntry(tupdesc, (AttrNumber) 4, "tbl_sync_error_count", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 5, "confl_insert_exists", INT8OID, -1, 0); @@ -2261,8 +2261,8 @@ pg_stat_get_subscription_stats(PG_FUNCTION_ARGS) /* seq_sync_error_count */ values[i++] = Int64GetDatum(subentry->seq_sync_error_count); - /* sync_error_count */ - values[i++] = Int64GetDatum(subentry->sync_error_count); + /* tbl_sync_error_count */ + values[i++] = Int64GetDatum(subentry->tbl_sync_error_count); /* conflict count */ for (int nconflict = 0; nconflict < CONFLICT_NUM_TYPES; nconflict++) diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 5cf9e12fcb9..6778caeaf54 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -5706,7 +5706,7 @@ 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,seq_sync_error_count,tbl_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}', prosrc => 'pg_stat_get_subscription_stats' }, { oid => '6118', descr => 'statistics: information about subscription', proname => 'pg_stat_get_subscription', prorows => '10', proisstrict => 'f', diff --git a/src/include/pgstat.h b/src/include/pgstat.h index a0610bb3e31..db7a997ee9d 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -110,7 +110,7 @@ typedef struct PgStat_BackendSubEntry { PgStat_Counter apply_error_count; PgStat_Counter seq_sync_error_count; - PgStat_Counter sync_error_count; + PgStat_Counter tbl_sync_error_count; PgStat_Counter conflict_count[CONFLICT_NUM_TYPES]; } PgStat_BackendSubEntry; @@ -419,7 +419,7 @@ typedef struct PgStat_StatSubEntry { PgStat_Counter apply_error_count; PgStat_Counter seq_sync_error_count; - PgStat_Counter sync_error_count; + PgStat_Counter tbl_sync_error_count; PgStat_Counter conflict_count[CONFLICT_NUM_TYPES]; TimestampTz stat_reset_timestamp; } PgStat_StatSubEntry; diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index 7c52181cbcb..20f9af130cb 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -2192,7 +2192,7 @@ pg_stat_subscription_stats| SELECT ss.subid, s.subname, ss.apply_error_count, ss.seq_sync_error_count, - ss.sync_error_count, + ss.tbl_sync_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, seq_sync_error_count, tbl_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); pg_stat_sys_indexes| SELECT relid, indexrelid, schemaname, diff --git a/src/test/subscription/t/026_stats.pl b/src/test/subscription/t/026_stats.pl index fc0bcee5187..272d85e2be4 100644 --- a/src/test/subscription/t/026_stats.pl +++ b/src/test/subscription/t/026_stats.pl @@ -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 seq_sync_error_count > 0 AND tbl_sync_error_count > 0 ]) or die qq(Timed out while waiting for sequencesync errors and tablesync errors for subscription '$sub_name'); @@ -176,7 +176,7 @@ is( $node_subscriber->safe_psql( $db, qq(SELECT apply_error_count > 0, seq_sync_error_count > 0, - sync_error_count > 0, + tbl_sync_error_count > 0, confl_insert_exists > 0, confl_delete_missing > 0, stats_reset IS NULL @@ -198,7 +198,7 @@ is( $node_subscriber->safe_psql( $db, qq(SELECT apply_error_count = 0, seq_sync_error_count = 0, - sync_error_count = 0, + tbl_sync_error_count = 0, confl_insert_exists = 0, confl_delete_missing = 0, stats_reset IS NOT NULL @@ -243,7 +243,7 @@ is( $node_subscriber->safe_psql( $db, qq(SELECT apply_error_count > 0, seq_sync_error_count > 0, - sync_error_count > 0, + tbl_sync_error_count > 0, confl_insert_exists > 0, confl_delete_missing > 0, stats_reset IS NULL @@ -264,7 +264,7 @@ is( $node_subscriber->safe_psql( $db, qq(SELECT apply_error_count = 0, seq_sync_error_count = 0, - sync_error_count = 0, + tbl_sync_error_count = 0, confl_insert_exists = 0, confl_delete_missing = 0, stats_reset IS NOT NULL @@ -279,7 +279,7 @@ is( $node_subscriber->safe_psql( $db, qq(SELECT apply_error_count = 0, seq_sync_error_count = 0, - sync_error_count = 0, + tbl_sync_error_count = 0, confl_insert_exists = 0, confl_delete_missing = 0, stats_reset IS NOT NULL -- 2.43.0