pgpool: Feature: load balancing control by table tracking.

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pgpool-committers(at)lists(dot)postgresql(dot)org
Subject: pgpool: Feature: load balancing control by table tracking.
Date: 2026-06-28 00:55:21
Message-ID: E1wddns-008iJb-2S@gothos.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-committers

Feature: load balancing control by table tracking.

Prevent routing of read only queries to standby if replication delay
of tables used in the query exceeds certain amount of value
collected by streaming replication process. To enable this feature,
set disable_load_balance_on_write to dml_adaptive_global.

In this mode, when tables are modified by
INSERT/UPDATE/DELETE/TRUNCATE/MERGE/data modification WITH, for
certain peoriod SELECTs using the tables are not load balanced:
i.e. routed to the primary PostgreSQL server to avoid the data
staleness by replication delay.

Unlike dml_adaptive mode, any table modifications decribed above are
detected even they happn in other sessions (in dml_adaptive, table
modifications are only detected in the same transaction). Note,
however, you cannot use dml_adaptive_object_relationship_list to track
dependency among table and other objects.

Besides dml_adaptive_global, there are some tuning knobs for the
feature:

- track_table_mutation_ttl_factor
Parameter to calculate TTL of each tracking data.

- track_table_mutation_max_staleness
Maximum duration in milliseconds that a single table entry can
continuously force queries to primary.

- track_table_mutation_cold_start_duration
Duration in milliseconds to route all queries to primary after a
child process starts.

- track_table_mutation_table_buckets
Number of hash buckets for the track table mutation hash table.

- track_table_mutation_table_size
Maximum number of tables that can be tracked simultaneously in the
track table mutation.

Author: Nadav Shatz <nadav(at)tailorbrands(dot)com>
Reviewed-by: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Japanese-docs-by: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Discussion: https://www.postgresql.org/message-id/flat/20260407.181009.1762204033074164841.ishii%40postgresql.org#58c139c1a7f8d5562865921d0733667b

Branch
------
master

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=243463af09513be0413f52917a1045836f50f339
Author: Nadav Shatz <nadav(at)tailorbrands(dot)com>

Modified Files
--------------
doc.ja/src/sgml/loadbalance.sgml | 274 +++++++
doc/src/sgml/loadbalance.sgml | 327 ++++++++
src/Makefile.am | 1 +
src/config/pool_config_variables.c | 65 ++
src/context/pool_query_context.c | 262 +++++-
src/context/pool_session_context.c | 19 +-
src/include/context/pool_session_context.h | 18 +-
src/include/pool.h | 3 +-
src/include/pool_config.h | 24 +-
src/include/utils/pool_track_table_mutation.h | 167 ++++
src/main/pgpool_main.c | 29 +-
src/protocol/CommandComplete.c | 49 ++
src/protocol/child.c | 8 +
src/protocol/pool_proto_modules.c | 6 +-
src/sample/pgpool.conf.sample-stream | 45 ++
src/streaming_replication/pool_worker_child.c | 24 +
src/test/regression/libs.sh | 2 +
.../tests/043.track_table_mutation/test.sh | 354 +++++++++
.../044.track_table_mutation_watchdog/test.sh | 184 +++++
src/tools/pgindent/typedefs.list | 4 +
src/utils/pool_track_table_mutation.c | 885 +++++++++++++++++++++
21 files changed, 2715 insertions(+), 35 deletions(-)

Browse pgpool-committers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-07-03 06:29:32 pgpool: Fix segfault in pool_do_auth().
Previous Message Bo Peng 2026-06-25 05:39:59 pgpool: Doc: Fix incorrect links.