pgpool2.git / summary / log / commit / refs
commit 91c85223dce3718cc321b582802e9c39f8b0a8b9
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Wed Sep 30 01:17:38 2026 +0000
Remove unused track_table_mutation statistics counters.
TrackTableMutationState carried three counters -- stats_queries_checked,
stats_forced_primary and stats_allowed_replica -- that were initialized and
incremented but never read. Nothing in the tree consumes them: there is no
SHOW command, reporting view or pcp command that exposes them, and the
pool_track_table_mutation_get_stats() accessor that would have done so was
removed before the feature was committed.
Maintaining them was not free. pool_track_table_mutation_table_is_stale()
released the table map semaphore after the lookup and then re-acquired it
solely to bump these counters, so every staleness check on every
load-balanceable SELECT paid a second trip through the semaphore to update
state no one could observe. Dropping the counters removes that critical
section entirely and lets the table_oid/dboid sanity check return directly
instead of jumping to a shared epilogue.
No functional change: the return value of
pool_track_table_mutation_table_is_stale() is unaffected for every input.
If exposing these numbers is wanted, they are better reintroduced together
with a way to read them -- a reporting view or a pcp command -- rather than
accumulated in shared memory with no consumer.
Author: Nadav Shatz <nadav@tailorbrands.com>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://www.postgresql.org/message-id/CACeKOO1v6%2BKiK-qns_37zCz7YYxJ6Zi_xKaLAuQcjkYQcjQu2Q%40mail.gmail.com
Backpatch-through: master only
src/include/utils/pool_track_table_mutation.h | 3 ---
src/utils/pool_track_table_mutation.c | 24 +-----------------------
2 files changed, 1 insertion(+), 26 deletions(-)
diff --git a/src/include/utils/pool_track_table_mutation.h b/src/include/utils/pool_track_table_mutation.h
index b60088c06..2e5970615 100644
--- a/src/include/utils/pool_track_table_mutation.h
+++ b/src/include/utils/pool_track_table_mutation.h
@@ -76,9 +76,6 @@ typedef struct TrackTableMutationState
struct timeval ttl_last_updated; /* When TTL was last updated */
struct timeval last_cleanup_time; /* When last expired cleanup ran */
struct timeval global_cold_start_until; /* Global cold start end time */
- uint32 stats_queries_checked; /* Queries checked */
- uint32 stats_forced_primary; /* Forced to primary */
- uint32 stats_allowed_replica; /* Allowed to replica */
} TrackTableMutationState;
/*
diff --git a/src/utils/pool_track_table_mutation.c b/src/utils/pool_track_table_mutation.c
index dd54792d1..b7d95b508 100644
--- a/src/utils/pool_track_table_mutation.c
+++ b/src/utils/pool_track_table_mutation.c
@@ -560,9 +560,6 @@ pool_track_table_mutation_init(void)
gettimeofday(&st->last_cleanup_time, NULL);
st->global_cold_start_until.tv_sec = 0;
st->global_cold_start_until.tv_usec = 0;
- st->stats_queries_checked = 0;
- st->stats_forced_primary = 0;
- st->stats_allowed_replica = 0;
ereport(LOG,
(errmsg("track_table_mutation: initialized with %zu bytes shmem",
@@ -698,10 +695,7 @@ pool_track_table_mutation_table_is_stale(
return false;
if (table_oid <= 0 || dboid <= 0)
- {
- is_stale = true;
- goto update_stats;
- }
+ return true;
map = track_table_mutation_shmem->table_map;
hash = fnv1a_hash_table_key(table_oid, dboid);
@@ -754,22 +748,6 @@ pool_track_table_mutation_table_is_stale(
table_map_unlock();
-update_stats:
- /* Update statistics using semaphore */
- if (track_table_mutation_shmem != NULL)
- {
- TrackTableMutationState *st;
-
- table_map_lock();
- st = &track_table_mutation_shmem->state;
- st->stats_queries_checked++;
- if (is_stale)
- st->stats_forced_primary++;
- else
- st->stats_allowed_replica++;
- table_map_unlock();
- }
-
return is_stale;
}
[parent: 17352edb15fa]