{{ message }}
Repository navigation
Conversation
Signed-off-by: Morchid Chellali <mc@wetransform.to>
7 tasks done
AndrewKhoma
suggested changes
Aug 17, 2026
AndrewKhoma
left a comment
Member
There was a problem hiding this comment.
thanks for opening this PR, but I need a better explanation on how you've been able to reproduce and execute this state with the running postgresql
AndrewKhoma
reviewed
Aug 17, 2026
| }), | ||
| Err(e) => { | ||
| tracing::warn!("Failed to get connection for pg_file_settings: {e}"); | ||
| Vec::new() |
Member
There was a problem hiding this comment.
this line and the line 102 (Vec::new() in unwrap_or_else) can be a potential bug you've faced, since we will drop all of the settings, not just the max_connections one in case of any failure instead of returning error
seems wrong to me, since in case of the error it's better to have stale GUCs then none
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Fixes #720. Supersedes #721 (see "Why this instead of #721").
max_connectionsis a startup GUC — it cannot change without a Postgres restart — yetPgConfiguration::max_connections()(configuration/pg_configuration.rs) re-reads it on every dynamic-config refresh and silently substitutes25on a bad/missing read. Becausemax_connectionsis part of thePgPoolSettingspool-cache key, that fabricated25flips the key mid-run with no real change behind it;get_data_poolthen permanently hard-fails every request for that user ("Connection pool missing for user.") — the pool is healthy but orphaned. Full root cause and log evidence: #720.This fixes the root cause: on a bad read,
max_connections()returns the last successfully-read value instead of fabricating a divergent one, so the pool key stays stable and the spurious miss never happens.Why this instead of #721
#721 made
get_data_poolfall back to reusing the user's existing pool on a settings-key miss. As @AndrewKhoma noted in review, that is unsafe: ifmax_connectionshad genuinely dropped to 25, the reused (100-sized) pool would let requests use connections Postgres no longer has (over-subscription); and the user-pool hard-fail is intentional precisely becausemax_connectionsis a startup GUC. This PR takes that feedback directly — it does not reuse pools and leaves the intentional hard-fail guard inget_data_pooluntouched. It only removes the spurious key flip at its source (the bad read). A genuinemax_connectionschange (via restart → fresh read) still updates the value and flips the key as designed, so the intended rebuild path is preserved.What changed
max_connections()caches the last valid read in anAtomicUsize(stored on every valid read); on a bad read it returns that last-known-good value, falling back to25only on the first-read edge case. Scope: one field onPgConfiguration+ the getter.Testing
cargo test -p documentdb_gateway_core→ 434 passed, 0 failed, including two new tests (last-known-good on bad read; falls back to 25 with no prior good value) and the existingvalidate_max_conn_change(a real change still flips the key → pool rebuild preserved).rustfmtandclippy --workspace --all-targets --all-features -- -D warningsclean on the repo's pinned toolchain (Rust 1.95).Type of Change
AI Disclosure
Checklist
cargo test— 434 passed)Signed-off-by: Morchid Chellali mc@wetransform.to