v20251024-0001-Rename-sync_error_count-to-tbl_sync_error_.patch

text/x-patch

Filename: v20251024-0001-Rename-sync_error_count-to-tbl_sync_error_.patch
Type: text/x-patch
Part: 0
Message: Re: Logical Replication of sequences

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v20251024-0001
Subject: Rename sync_error_count to tbl_sync_error_count
File+
doc/src/sgml/monitoring.sgml 1 1
src/backend/catalog/system_views.sql 1 1
src/backend/utils/activity/pgstat_subscription.c 2 2
src/backend/utils/adt/pgstatfuncs.c 3 3
src/include/catalog/pg_proc.dat 1 1
src/include/pgstat.h 2 2
src/test/regress/expected/rules.out 2 2
src/test/subscription/t/026_stats.pl 19 15
From 57b2a0948ee298206c71ece7204136f715efe6f1 Mon Sep 17 00:00:00 2001
From: Vignesh C <vignesh21@gmail.com>
Date: Fri, 24 Oct 2025 18:54:37 +0530
Subject: [PATCH v20251024 1/4] Rename sync_error_count to tbl_sync_error_count

The variable sync_error_count has been renamed to tbl_sync_error_count to
make its purpose explicit and to avoid confusion with upcoming changes that
will introduce a separate seq_sync_error_count for sequence synchronization
errors. This renaming helps clarify that the counter specifically tracks
table synchronization errors and ensures better distinction when sequence
sync will be supported in future patches.
---
 doc/src/sgml/monitoring.sgml                  |  2 +-
 src/backend/catalog/system_views.sql          |  2 +-
 .../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          | 34 +++++++++++--------
 8 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index d5f0fb7ba7c..1afdcd703c5 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -2194,7 +2194,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>tbl_sync_error_count</structfield> <type>bigint</type>
       </para>
       <para>
        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 823776c1498..77acf8f2798 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -1414,7 +1414,7 @@ CREATE VIEW pg_stat_subscription_stats AS
         ss.subid,
         s.subname,
         ss.apply_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 f9a1c831a07..89dc04a72a2 100644
--- a/src/backend/utils/activity/pgstat_subscription.c
+++ b/src/backend/utils/activity/pgstat_subscription.c
@@ -36,7 +36,7 @@ pgstat_report_subscription_error(Oid subid, bool is_apply_error)
 	if (is_apply_error)
 		pending->apply_error_count++;
 	else
-		pending->sync_error_count++;
+		pending->tbl_sync_error_count++;
 }
 
 /*
@@ -115,7 +115,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(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 1fe33df2756..f07efcc4530 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -2213,7 +2213,7 @@ 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, "sync_error_count",
+	TupleDescInitEntry(tupdesc, (AttrNumber) 3, "tbl_sync_error_count",
 					   INT8OID, -1, 0);
 	TupleDescInitEntry(tupdesc, (AttrNumber) 4, "confl_insert_exists",
 					   INT8OID, -1, 0);
@@ -2248,8 +2248,8 @@ pg_stat_get_subscription_stats(PG_FUNCTION_ARGS)
 	/* apply_error_count */
 	values[i++] = Int64GetDatum(subentry->apply_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 eecb43ec6f0..754133f227e 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,timestamptz}',
   proargmodes => '{i,o,o,o,o,o,o,o,o,o,o,o,o}',
-  proargnames => '{subid,subid,apply_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,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 bc8077cbae6..90fb622357e 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -108,7 +108,7 @@ typedef struct PgStat_FunctionCallUsage
 typedef struct PgStat_BackendSubEntry
 {
 	PgStat_Counter apply_error_count;
-	PgStat_Counter sync_error_count;
+	PgStat_Counter tbl_sync_error_count;
 	PgStat_Counter conflict_count[CONFLICT_NUM_TYPES];
 } PgStat_BackendSubEntry;
 
@@ -416,7 +416,7 @@ typedef struct PgStat_SLRUStats
 typedef struct PgStat_StatSubEntry
 {
 	PgStat_Counter apply_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 16753b2e4c0..166b9f8c89f 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -2191,7 +2191,7 @@ pg_stat_subscription| SELECT su.oid AS subid,
 pg_stat_subscription_stats| SELECT ss.subid,
     s.subname,
     ss.apply_error_count,
-    ss.sync_error_count,
+    ss.tbl_sync_error_count,
     ss.confl_insert_exists,
     ss.confl_update_origin_differs,
     ss.confl_update_exists,
@@ -2202,7 +2202,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, 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, 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 00a1c2fcd48..e8d3ff3fe65 100644
--- a/src/test/subscription/t/026_stats.pl
+++ b/src/test/subscription/t/026_stats.pl
@@ -63,7 +63,7 @@ sub create_sub_pub_w_errors
 	$node_subscriber->poll_query_until(
 		$db,
 		qq[
-	SELECT sync_error_count > 0
+	SELECT tbl_sync_error_count > 0
 	FROM pg_stat_subscription_stats
 	WHERE subname = '$sub_name'
 	])
@@ -140,11 +140,12 @@ my ($pub1_name, $sub1_name) =
   create_sub_pub_w_errors($node_publisher, $node_subscriber, $db,
 	$table1_name);
 
-# Apply errors, sync errors, and conflicts are > 0 and stats_reset timestamp is NULL
+# Apply errors, tablesync errors, and conflicts are > 0 and stats_reset
+# timestamp is NULL.
 is( $node_subscriber->safe_psql(
 		$db,
 		qq(SELECT apply_error_count > 0,
-	sync_error_count > 0,
+	tbl_sync_error_count > 0,
 	confl_insert_exists > 0,
 	confl_delete_missing > 0,
 	stats_reset IS NULL
@@ -152,7 +153,7 @@ is( $node_subscriber->safe_psql(
 	WHERE subname = '$sub1_name')
 	),
 	qq(t|t|t|t|t),
-	qq(Check that apply errors, sync errors, and conflicts are > 0 and stats_reset is NULL for subscription '$sub1_name'.)
+	qq(Check that apply errors, tablesync errors, and conflicts are > 0 and stats_reset is NULL for subscription '$sub1_name'.)
 );
 
 # Reset a single subscription
@@ -160,11 +161,12 @@ $node_subscriber->safe_psql($db,
 	qq(SELECT pg_stat_reset_subscription_stats((SELECT subid FROM pg_stat_subscription_stats WHERE subname = '$sub1_name')))
 );
 
-# Apply errors, sync errors, and conflicts are 0 and stats_reset timestamp is not NULL
+# Apply errors, tablesync errors, and conflicts are 0 and stats_reset timestamp
+# is not NULL.
 is( $node_subscriber->safe_psql(
 		$db,
 		qq(SELECT apply_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
@@ -172,7 +174,7 @@ is( $node_subscriber->safe_psql(
 	WHERE subname = '$sub1_name')
 	),
 	qq(t|t|t|t|t),
-	qq(Confirm that apply errors, sync errors, and conflicts are 0 and stats_reset is not NULL after reset for subscription '$sub1_name'.)
+	qq(Confirm that apply errors, tablesync errors, and conflicts are 0 and stats_reset is not NULL after reset for subscription '$sub1_name'.)
 );
 
 # Get reset timestamp
@@ -202,11 +204,12 @@ my ($pub2_name, $sub2_name) =
   create_sub_pub_w_errors($node_publisher, $node_subscriber, $db,
 	$table2_name);
 
-# Apply errors, sync errors, and conflicts are > 0 and stats_reset timestamp is NULL
+# Apply errors, tablesync errors, and conflicts are > 0 and stats_reset
+# timestamp is NULL.
 is( $node_subscriber->safe_psql(
 		$db,
 		qq(SELECT apply_error_count > 0,
-	sync_error_count > 0,
+	tbl_sync_error_count > 0,
 	confl_insert_exists > 0,
 	confl_delete_missing > 0,
 	stats_reset IS NULL
@@ -214,18 +217,19 @@ is( $node_subscriber->safe_psql(
 	WHERE subname = '$sub2_name')
 	),
 	qq(t|t|t|t|t),
-	qq(Confirm that apply errors, sync errors, and conflicts are > 0 and stats_reset is NULL for sub '$sub2_name'.)
+	qq(Confirm that apply errors, tablesync errors, and conflicts are > 0 and stats_reset is NULL for sub '$sub2_name'.)
 );
 
 # Reset all subscriptions
 $node_subscriber->safe_psql($db,
 	qq(SELECT pg_stat_reset_subscription_stats(NULL)));
 
-# Apply errors, sync errors, and conflicts are 0 and stats_reset timestamp is not NULL
+# Apply errors, tablesync errors, and conflicts are 0 and stats_reset timestamp
+# is not NULL.
 is( $node_subscriber->safe_psql(
 		$db,
 		qq(SELECT apply_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
@@ -233,13 +237,13 @@ is( $node_subscriber->safe_psql(
 	WHERE subname = '$sub1_name')
 	),
 	qq(t|t|t|t|t),
-	qq(Confirm that apply errors, sync errors, and conflicts are 0 and stats_reset is not NULL for sub '$sub1_name' after reset.)
+	qq(Confirm that apply errors, tablesync errors, and conflicts are 0 and stats_reset is not NULL for sub '$sub1_name' after reset.)
 );
 
 is( $node_subscriber->safe_psql(
 		$db,
 		qq(SELECT apply_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
@@ -247,7 +251,7 @@ is( $node_subscriber->safe_psql(
 	WHERE subname = '$sub2_name')
 	),
 	qq(t|t|t|t|t),
-	qq(Confirm that apply errors, sync errors, and conflicts are 0 and stats_reset is not NULL for sub '$sub2_name' after reset.)
+	qq(Confirm that apply errors, tablesync errors, and conflicts are 0 and stats_reset is not NULL for sub '$sub2_name' after reset.)
 );
 
 $reset_time1 = $node_subscriber->safe_psql($db,
-- 
2.43.0