fix: initialize pool sizing before queue workers start - #1329
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a startup-order bug where tenant pool sizing and cluster discovery could be initialized after queue workers start, allowing workers to create pools using an incorrect cached numWorkers multiplier until cache expiry.
Changes:
- Move
PgTenantConnection.poolManagerinitialization (setNumWorkers/monitor) ahead of queue startup. - Move
Cluster.initand cluster change handling ahead of queue startup to ensure pools created by queue workers are sized with correct cluster context. - Add a Vitest regression test to assert boot order (pool sizing + cluster discovery happen before queue starts).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/start/server.ts | Reorders startup to initialize pool sizing and cluster discovery before queue workers can create tenant pools. |
| src/start/server.test.ts | Adds a boot-order regression test to prevent future startup-order regressions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ferhatelmas
force-pushed
the
ferhat/sizing-order
branch
from
August 14, 2026 15:53
1b65bd0 to
0ab9cc1
Compare
Coverage Report for CI Build 31817125840Coverage decreased (-0.06%) to 81.129%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
ferhatelmas
force-pushed
the
ferhat/sizing-order
branch
from
August 14, 2026 15:58
0ab9cc1 to
933a0c9
Compare
itslenny
approved these changes
Aug 14, 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
What is the current behavior?
Queue workers are started before pool sizing and cluster discovery.
Pool strategy caches num of workers but it's never rebalanced unlike cluster size.
If a strategy is cached during that window, it will be using more connections (x numWorkers) until expire (or indefinitely by capacity).
What is the new behavior?
Do it before queue start.
It doesn't apply worker entrypoint since their multiplier is always one.
Additional context
Seal the order via a test.