Repository navigation
Conversation
…ta_pool Signed-off-by: Morchid Chellali <[email protected]>
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (gateway); effort from diff stats (72+9 LOC, 1 files); LLM: Fixes a permanent hard-failure for all requests per user when a settings-key miss occurs in get_data_pool due to GUC re-read drift — an active blocker in production gateway scenarios. If a label is wrong, remove it manually and ping |
| .user_data_pools | ||
| .iter() | ||
| .find(|entry| entry.key().0 == username) | ||
| .map(|entry| Arc::clone(entry.value())); |
There was a problem hiding this comment.
but the pool you've received will not govern the gw of using the 25 connections as in your test case, but will let to go the whole 100 connections (which it doesn't have).
the whole rationale of why we don't have this logic for the user data pools is because the max_connections is the startup GUC, so I would expect the whole docker restart so the pg can pick up the new param too; if your use case requires the dynamic change I highly recommend changing the
user_data_pools: DashMap<ClientKey, Arc<ConnectionPool>> to something like
user_data_pools: DashMap<(ClientKey, PgPoolSettings), Arc<ConnectionPool>>
so in case any pg pool settings changes you will use the "fresh" pool and the old pool will be cleaned up on retention
|
Thanks @AndrewKhoma — agreed on both points. Closing this in favor of #723, which takes that feedback directly — instead of reusing pools it fixes the root cause: the transient bad |
Description
Fixes #720.
get_data_pool(postgres/conn_mgmt/pool_manager.rs) keys the per-user pool cache on(username, PgPoolSettings).PgPoolSettingsincludesmax_connections, which is re-read from a Postgres GUC on every dynamic-config refresh (and silently defaults to25on a bad read). When it changes, the exact-key lookup misses and the gateway hard-fails every request for that user — permanently — even though their pool is still present and healthy. This PR makesget_data_poolreuse the user's existing pool on a settings-key miss instead of erroring. Root cause and evidence: #720.What changed
get_data_poolkeeps the exact-key fast path, and on a miss reuses any existing pool for thatusernamebefore erroring (illustrative):Plus a regression test (
test_get_data_pool_falls_back_to_existing_pool_on_settings_change): allocate a pool, flipmax_connections, assertget_data_poolreturns the same pool (Arc::ptr_eq) with no new pool created.Why it's correct
allocate_data_poolre-files the pool under the current key on the next authentication, so this only bridges the gap for already-authenticated users — it isn't a permanent bypass. The exact-key hit path is untouched, so the deliberate rebuild-on-max_connections-change (validate_max_conn_change) still works.Why not mirror
get_system_shared_poolThat path self-heals by building a new pool from system credentials it always holds.
get_data_poolhas no user password at request time (onlyallocate_data_poolhas it, at auth), so reusing the existing pool is the only option here.Alternatives considered
max_connectionsfrom the key — rejected: rebuilding pools on a realmax_connectionschange is intentional/tested (validate_max_conn_change).max_connections()to not fabricate25— good complementary defense-in-depth, but a legitimatemax_connectionschange flips the same key and hits the same miss, so it's not a substitute. Happy to add as a follow-up.Testing
cargo test -p documentdb_gateway_core pool_manager→ 13 passed, 0 failed (the new test, the no-pool-still-errors case, andvalidate_max_conn_change).rustfmt+clippy --workspace --all-targets --all-features -- -D warningsclean on the pinned toolchain.Type of Change
AI Disclosure
Checklist
cargo test— 13 passed)Signed-off-by: Morchid Chellali [email protected]