fix: on tenant config change#1100
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes tenant-config-driven pool rebalancing so that changing max_connections rebalances cached pools by updating max connections (instead of incorrectly treating it as clusterSize), and allows reverting back to the default DATABASE_MAX_CONNECTIONS. Adds regression tests for the expected rebalance contract.
Changes:
- Export
onTenantConfigChangeand update it to compare/resolvemaxConnectionscorrectly (including default fallback) before triggering a rebalance. - Extend pool rebalance plumbing to accept
maxConnectionsupdates (in addition toclusterSize) and recreate the underlying Knex pool when either changes. - Add tests covering tenant-config-triggered rebalance (no destroy) and pool recreation with updated max connections.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/test/tenant.test.ts | Adds a test asserting max_connections changes trigger poolManager.rebalance (and do not destroy the pool). |
| src/internal/database/tenant.ts | Fixes tenant-config-change handling to rebalance using maxConnections (with normalization + default fallback) and exports the handler for testing. |
| src/internal/database/pool.ts | Updates rebalance APIs to support { maxConnections } updates and applies them by recreating the cached Knex pool. |
| src/internal/database/pool.test.ts | Adds a test verifying rebalance recreates a tenant pool with a new max-connection setting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 25721679492Coverage increased (+0.07%) to 74.372%Details
Uncovered Changes
Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats💛 - Coveralls |
fenos
approved these changes
May 12, 2026
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
04feaa9 to
89d16b5
Compare
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
What is the current behavior?
Pool rebalance was mixing cluster size and max connections, and wrongly setting cluster size. Reverting to default isn't possible either.
What is the new behavior?
Keep cluster size and max connection and normalize their values so that cluster size or max connection change do rebalance.
Additional context
Add tests to ensure the contract.