fix: rebalance over recycle on only tenant config conn change#1140
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts multitenant DB pool handling so that tenant config changes affecting only maxConnections no longer recycle (destroy/recreate) the cached pool, but instead rebalance it in place to reduce connection/socket churn while still applying increases immediately and letting decreases drain via normal idle behavior.
Changes:
- Update
onTenantConfigChangeto callPoolManager.rebalance(...)when onlymaxConnectionschanges (and stilldestroy(...)on endpoint/pool-mode changes). - Add a targeted
PoolManager.rebalance(tenantId, options)API and remove the previousrecycle(...)API. - Update/add tests to validate rebalance behavior and the removal of
recycle.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/test/tenant.test.ts | Updates tenant-config change tests to expect rebalance (not recycle) on maxConnections changes. |
| src/internal/database/tenant.ts | Switches max-connection-change handling from pool recycle to in-place rebalance; removes unused recycle settings builder. |
| src/internal/database/pool.ts | Adds PoolManager.rebalance forwarding method and removes PoolManager.recycle. |
| src/internal/database/pool.test.ts | Adds coverage for PoolManager.rebalance forwarding and asserts recycle is no longer part of the API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
0959b5b to
adfdc93
Compare
Coverage Report for CI Build 27134423353Coverage decreased (-0.009%) to 76.438%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
fenos
approved these changes
Jun 8, 2026
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.
What kind of change does this PR introduce?
Bug fix (performance improvement)
What is the current behavior?
On only max connections change for tenant config, pool is recycled which creates unnecessary connection/socket churn.
What is the new behavior?
Mutates the pool in place, increases are immediate and decreases are handled by idle timeout.
Additional context
Related to #1125 - prior approach
Related to #1096 - already has this approach