| From: | Nadav Shatz <nadav(at)tailorbrands(dot)com> |
|---|---|
| To: | pgpool-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Proposal: Recent mutated table tracking in memory |
| Date: | 2026-01-14 08:55:41 |
| Message-ID: | CACeKOO1NBExVWG0=wMKc+Kpk-RFXM2i1XTqzGdB9Z_pqg+5otg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgpool-hackers |
Hi all,
Any comments or concerns? can we merge it if not?
On Tue, Jan 6, 2026 at 1:25 PM Nadav Shatz <nadav(at)tailorbrands(dot)com> wrote:
> Hello,
>
> As initially proposed under "Proposal: recent access based routing for
> primary-replica setups" and then broken into separate tasks - i am adding
> here a patch to implement tracking of latest mutated table, and then using
> the replication lag as a base - deciding where to point queries when query
> load balancing and parsing is enabled.
>
> More details as in the patch:
> Feature: add in-memory table tracking to prevent stale reads from replicas
>
> Implement "memory map" feature that tracks recently-written database
> tables in shared memory to prevent stale reads during replication lag.
> When a write (INSERT/UPDATE/DELETE) occurs on a table, that table is
> marked as "dirty" for a configurable TTL period. Any SELECT on a dirty
> table within the TTL window is routed to primary instead of replica.
>
> Key features:
> - Shared memory hash table for tracking table mutations with TTL
> - Query parse cache with LRU eviction for performance
> - Cold start protection (routes all queries to primary initially)
> - Automatic TTL calculation: replication_delay × configurable factor
> - Per-table staleness tracking with microsecond precision
>
> New configuration parameters:
> - memory_map_enabled: Enable/disable the feature (default: off)
> - memory_map_ttl_factor: TTL multiplier for replication delay (default:
> 5.0)
> - memory_map_cold_start_duration: Cold start period in ms (default: 2000)
> - memory_map_table_buckets: Hash buckets for table map (default: 1024)
> - memory_map_table_size: Max tracked tables (default: 2048)
> - memory_map_query_buckets: Hash buckets for query cache (default: 2048)
> - memory_map_query_cache_size: Max cached queries (default: 10000)
>
> Patch applies properly and tests pass.
>
> Open to all feedback - thank you!
>
> --
> Nadav Shatz
> Tailor Brands | CTO
>
--
Nadav Shatz
Tailor Brands | CTO
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nadav Shatz | 2026-01-26 11:02:40 | Re: Proposal: Recent mutated table tracking in memory |
| Previous Message | Tatsuo Ishii | 2026-01-08 05:44:52 | Re: Proposal: recent access based routing for primary-replica setups |