fix(db): retry initial Mongo connection to avoid worker crash-loop#559
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the MongoDB DatabaseController.connect() startup behavior so workers don’t crash-loop when MongoDB is temporarily unreachable, by retrying the initial connection handshake with a fixed delay and a bounded server-selection timeout.
Changes:
- Add configurable retry loop for the initial MongoDB connection attempt (
MONGO_RECONNECT_TRIES,MONGO_RECONNECT_INTERVAL). - Add
serverSelectionTimeoutMSto ensure each attempt fails fast during outages. - Adjust
connect()to return the existingDbinstance when already connected.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
neSpecc
previously approved these changes
Jun 10, 2026
neSpecc
approved these changes
Jun 10, 2026
Kuchizu
added a commit
that referenced
this pull request
Jun 12, 2026
* feat(grouper): add slow handle diagnostics (#549) * feat(grouper): add slow handle diagnostics * refactor(grouper): extract slow handle diagnostics into session * fix(grouper): use monotonic time and exclusive timings in slow handle diagnostics * fix(db): retry initial Mongo connection to avoid worker crash-loop (#559) * fix(db): retry initial Mongo connection to avoid worker crash-loop * fix(db): clamp Mongo reconnect env vars and test retry loop * refactor(db): move positiveIntEnv to utils * fix(task-manager): use event._id instead of groupHash in issue event URL (#569) * Initial plan * fix: use event._id instead of groupHash in task-manager event URL --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --------- Co-authored-by: Kuchizu <70284260+Kuchizu@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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.
DatabaseController.connect() now retries the initial handshake instead of throwing on the first failure.