Skip to content

fix(sync): guard db sync against a stopped local DB container - #112

Merged
ddtcorex merged 1 commit into
masterfrom
fix/sync-db-ensure-local-container-running
Aug 5, 2026
Merged

fix(sync): guard db sync against a stopped local DB container#112
ddtcorex merged 1 commit into
masterfrom
fix/sync-db-ensure-local-container-running

Conversation

@ddtcorex

@ddtcorex ddtcorex commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • sync --db (both directions) built and ran the docker exec dump/import
    pipeline against the local DB container without ever checking it was
    running, unlike db import --stream-db / db dump/db import -f, which
    already guard this via ensureLocalDBRunning.
  • Against a stopped/missing local container, docker exec can behave
    unpredictably instead of failing fast - in the reported case, the whole
    sync --db command hung indefinitely with no error.
  • Root-caused via a SIGQUIT goroutine dump of the stuck process: the main
    goroutine was blocked in importCmd.Wait() (db.go:1113) after the remote
    dump had already finished - so the remote/SSH side was never the problem.
    Confirmed with the reporting user: running govard env up first (bringing
    the local container up) made the exact same sync --db command succeed.
  • Added the same ensureLocalDBRunning guard to both sync-direction action
    closures in buildDatabaseSyncAction, right before the docker exec command
    is built/run - so a stopped container now fails immediately with
    database container <name> is not running instead of hanging.

Closes #111

Test plan

  • Added TestSyncPlanDatabaseActionFailsFastWhenLocalContainerNotRunning
    (tests/sync_plan_test.go) - runs the actual returned DB action closure
    against a hermetic test environment with no real container, asserting
    it fails fast with a clear "is not running" error instead of hanging
  • Existing TestSyncPlanScopes / TestSyncPlanDatabaseStopsWhenRemoteCredentialsCannotBeResolved
    still pass (the guard lives inside the action closure, not at plan-build
    time, so hermetic plan-building tests are unaffected)
  • go build ./..., go vet ./..., go test ./... all pass
  • gofmt -s -l . shows no drift on changed files

sync --db built and ran the remote-dump/local-import (or reverse) docker
exec pipeline without ever checking the local DB container was running,
unlike db import --stream-db and db dump/import -f, which already guard
this via ensureLocalDBRunning. Against a stopped/missing container,
docker exec can behave unpredictably (including hanging indefinitely)
instead of failing fast with a clear error.

Root-caused via a SIGQUIT goroutine dump showing the main goroutine
blocked in importCmd.Wait() (db.go:1113) after the remote dump had
already finished - confirmed by the user: running `govard env up`
first made the exact same sync --db command work.

Add the same ensureLocalDBRunning guard at the start of each sync
direction's action closure, right before touching docker exec.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ddtcorex
ddtcorex merged commit 936ca8f into master Aug 5, 2026
7 checks passed
@ddtcorex
ddtcorex deleted the fix/sync-db-ensure-local-container-running branch August 5, 2026 17:17
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.

govard sync --db hangs indefinitely when the local DB container isn't running

1 participant