Repository navigation
fix(db): handle MySQL post-upgrade startup delay gracefully (re: #1137) - #1138
Open
riteshyadav33302111-cell wants to merge 1 commit into
Open
riteshyadav33302111-cell wants to merge 1 commit into
riteshyadav33302111-cell wants to merge 1 commit into
Conversation
…t-org#1137) After a MySQL version update, the server runs upgrade/migration steps before it can fully accept connections. This caused a 502 error that required a manual ./shift down && ./shift up to clear. Three-layer fix: 1. docker-compose.yml: add a healthcheck on the db service using mysqladmin ping, with a 30s start_period and 10 retries (5s interval) to cover the extended init window after a version upgrade. 2. docker-compose.yml: make the node service depend on db with condition: service_healthy, so Docker Compose holds node until MySQL is fully ready -- not just started. 3. app/db.js: add waitForConnection() with exponential-backoff retry (up to ~63s across 6 attempts) as a defence-in-depth layer. If a timing edge-case slips past the healthcheck, the node process retries the connection itself instead of crashing and requiring a human to bounce the server. 4. shift: raise MAX_TRIES from 5 to 20 so ./shift up waits long enough when a MySQL upgrade genuinely takes extra time before node can print its ready message.
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.
After a MySQL version update, the server runs upgrade/migration steps before it can fully accept connections. This caused a 502 error that required a manual ./shift down && ./shift up to clear.
Three-layer fix:
docker-compose.yml: add a healthcheck on the db service using mysqladmin ping, with a 30s start_period and 10 retries (5s interval) to cover the extended init window after a version upgrade.
docker-compose.yml: make the node service depend on db with condition: service_healthy, so Docker Compose holds node until MySQL is fully ready -- not just started.
app/db.js: add waitForConnection() with exponential-backoff retry (up to ~63s across 6 attempts) as a defence-in-depth layer. If a timing edge-case slips past the healthcheck, the node process retries the connection itself instead of crashing and requiring a human to bounce the server.
shift: raise MAX_TRIES from 5 to 20 so ./shift up waits long enough when a MySQL upgrade genuinely takes extra time before node can print its ready message.