Repository navigation
fix(db): clear the ready marker when the database starts - #5421
Merged
Merged
Conversation
The entrypoint only ever touched /tmp/.db_ready. /tmp outlives a stop whenever the runtime keeps the container's filesystem, as `docker restart` does, so a restarted database read the previous start's marker and reported ready as soon as Postgres answered, before this start's init scripts and migrations ran. Clear the marker before the background init block. services/db gains a test script. Its Bun test checks that the clear is a top-level line before the background block and its touch, and runs the real entrypoint twice with a fake server: on the restart the server starts with no marker, and the marker returns once init has finished.
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.
Summary
The database entrypoint only ever created the ready marker
/tmp/.db_ready; nothing cleared it./tmpoutlives a stop whenever the runtime keeps the container's filesystem, asdocker restartdoes, so a restarted database read the previous start's marker and reported ready (HEALTHCHECK, compose waits, CLI and CI waits) as soon as Postgres answered, before this start's init scripts and migrations had run.The fix clears the marker with a top-level
rm -f /tmp/.db_readybefore the background init block, so the marker only exists once this start's init has finished.services/dbgains atestscript and a Bun test for the entrypoint.Checklist
bun run checkpasses — the new and touched parts pass; on the test VM the remaining failures (@tale/cli#test,@tale/platform#test:ui,@tale/session-manager#test) are the same on a cleanorigin/mainworktree there (VM environment: no docker compose plugin, memory, timing) and none depends on@tale/db. CI is the reference.bun run lint:sast— N/A: a shell line and a test; no SAST-relevant surface./tmp/.db_ready) stays true and now also holds after a restart.Test plan
bun test services/db: 2 tests pass (run 3 times). A structural test checks that the clear is a top-level line before the background block and itstouch; a behavioural test runs the real entrypoint twice under bash with a fake server: on the restart the server starts with no marker, and the marker returns once init has finished. With the fix reverted, both tests fail (the restart reads the stale marker).tscon the new test: clean. knip, format:check, lint:conflicts, lint:links: clean. commitlint: clean.mainand from this branch, ran each, thendocker restart. Onmainthe marker was present in every sample taken whilepg_isreadyanswered and before the secondDatabase ready.; with the fix it was absent in every such sample and present after init finished.