Skip to content

fix: on tenant config change#1100

Merged
ferhatelmas merged 1 commit into
masterfrom
ferhat/on-tenat-config
May 12, 2026
Merged

fix: on tenant config change#1100
ferhatelmas merged 1 commit into
masterfrom
ferhat/on-tenat-config

Conversation

@ferhatelmas
Copy link
Copy Markdown
Member

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.

Copilot AI review requested due to automatic review settings May 11, 2026 17:21
@ferhatelmas ferhatelmas requested a review from a team as a code owner May 11, 2026 17:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 onTenantConfigChange and update it to compare/resolve maxConnections correctly (including default fallback) before triggering a rebalance.
  • Extend pool rebalance plumbing to accept maxConnections updates (in addition to clusterSize) 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.

@coveralls
Copy link
Copy Markdown

coveralls commented May 11, 2026

Coverage Report for CI Build 25721679492

Coverage increased (+0.07%) to 74.372%

Details

  • Coverage increased (+0.07%) from the base build.
  • Patch coverage: 3 uncovered changes across 1 file (10 of 13 lines covered, 76.92%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
src/internal/database/pool.ts 9 6 66.67%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
src/internal/database/pool.ts 1 82.59%

Coverage Stats

Coverage Status
Relevant Lines: 10297
Covered Lines: 8066
Line Coverage: 78.33%
Relevant Branches: 5951
Covered Branches: 4018
Branch Coverage: 67.52%
Branches in Coverage %: Yes
Coverage Strength: 410.84 hits per line

💛 - Coveralls

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
@ferhatelmas ferhatelmas force-pushed the ferhat/on-tenat-config branch from 04feaa9 to 89d16b5 Compare May 12, 2026 08:04
@ferhatelmas ferhatelmas merged commit 58c2ca7 into master May 12, 2026
18 checks passed
@ferhatelmas ferhatelmas deleted the ferhat/on-tenat-config branch May 12, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants