CS-697 - apply connection pool size changes without a restart - #38050
Open
jubrad wants to merge 1 commit into
Open
CS-697 - apply connection pool size changes without a restart #38050jubrad wants to merge 1 commit into
jubrad wants to merge 1 commit into
Conversation
jubrad
marked this pull request as ready for review
August 4, 2026 20:14
5 tasks
jubrad
force-pushed
the
crdb-pool-live-resize
branch
2 times, most recently
from
August 5, 2026 16:27
ebfb212 to
60658ce
Compare
Upgrade deadpool 0.9.5 -> 0.12.3 and deadpool-postgres 0.10.3 -> 0.14.1 to get access to Pool::resize, and wire PostgresClient::get_connection to apply a changed connection_pool_max_size knob to the live pool on the next acquire. persist_consensus_connection_pool_max_size and pg_timestamp_oracle_connection_pool_max_size previously required a process restart to take effect, which made the pool cap unusable as an operational lever during CRDB maintenance or incidents. Note a monitoring behavior change that comes with the deadpool upgrade: the connpool_available metric is now a non-negative idle count. Acquires queued on an exhausted pool were previously visible as negative available and are no longer externally observable. The deadpool API migration itself: the Manager trait is natively async, recycle takes a Metrics argument, and pre_recycle hook errors are constructed with HookError::message. The TTL-culling semantics of the pre_recycle hook are unchanged. deadpool 0.12 requires lazy_static 1.5, which moves the duplicate-spin skip in deny.toml from 0.5.2 to 0.9.9. Adds a pool_resize_applies_on_acquire test in mz-postgres-client that verifies grow and shrink both apply on acquire. It opts in via the same MZ_PERSIST_EXTERNAL_STORAGE_TEST_POSTGRES_URL variable as the persist external-storage tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
jubrad
force-pushed
the
crdb-pool-live-resize
branch
from
August 5, 2026 16:27
60658ce to
b653ede
Compare
5 tasks
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.
Motivation
During a recent CockroachDB rolling upgrade we observed persist consensus connection pools exhausting on every node drain: each drain force-closes its share of pooled connections, deadpool silently discards them on recycle, and acquires queue while the pool re-creates connections on demand. On the busiest environments the acquire queue reached thousands of waiters, stalling every persist operation on that process and degrading freshness.
The pool cap (
persist_consensus_connection_pool_max_size,pg_timestamp_oracle_connection_pool_max_size) is the natural operational lever here, but it was read once at pool construction and required a process restart to change. This PR makes it apply to live pools, so it can be raised (or lowered) fleet-wide via dyncfg ahead of planned CRDB maintenance or during an incident.Changes
deadpool0.9.5 → 0.12.3 anddeadpool-postgres0.10.3 → 0.14.1 to getPool::resize. API migration:Manageris natively async,recycletakes aMetricsargument,pre_recyclehook errors useHookError::message. TTL-culling semantics are unchanged.PostgresClient::get_connectionnow compares the knob against the pool's currentmax_sizeand callsPool::resizeon mismatch, so both consensus and timestamp oracle pools pick up knob changes on the next acquire. Both knob implementations already read live values (dyncfg / atomics), so no plumbing changes were needed there.*_postgres_connpool_availableis a non-negative idle count. Acquires queued on an exhausted pool were previously visible as negativeavailable; dashboards/alerts keying on negativeavailablewill no longer fire.deny.toml: deadpool 0.12 requireslazy_static1.5, so add it as a wrapper for thelazy_staticban and move the duplicate-spinskip from 0.5.2 to 0.9.9.Tests
pool_resize_applies_on_acquiretest inmz-postgres-clientverifying grow and shrink both apply on acquire, opted in viaMZ_PERSIST_EXTERNAL_STORAGE_TEST_POSTGRES_URLlike the persist external-storage tests.mz-persistconsensus andmz-timestamp-oracletests pass.postgres::tests::postgres_consensusfails whenMZ_PERSIST_EXTERNAL_STORAGE_TEST_POSTGRES_URLpoints at a CockroachDB backend, because the read-committed re-run trips theget_connectionserializable assertion that refuses READ COMMITTED on CRDB. The test comment expects the flag to be a no-op on CRDB, but the isolation resolver follows the flag unconditionally. Will file separately.Checklist
$T ⇔ Proto$Tmapping (possibly in a backwards-incompatible way), then it is tagged with aT-protolabel.🤖 Generated with Claude Code