Skip to content

fix(infra): a removed worktree leaves its postgres container running, and two of them break every checkout #2107

Description

@janlauber

Split out of #2105 — a different mechanism, same root cause: git worktree remove runs no hook.

What happens

A worktree that ran make infra starts its own compose project. Removing the worktree leaves the container running, and scripts/dev-env.sh's pg_container refuses as soon as it finds more than one:

dev-env.sh: no single postgres container to use — run `make infra` (in any
checkout; they share one server), or set WATTROOM_PG_CONTAINER when several
are running

That is not a per-worktree failure. It breaks make dev-server, make test and now make worktree-gc for every checkout on the machine, including the main tree, until someone sets WATTROOM_PG_CONTAINER or finds the stray container.

Right now

mic-camera-selection-ui-70d898-postgres-1   5432/tcp                     <- worktree removed 2026-09-10
blissful-tesla-682eac-postgres-1            0.0.0.0:5432->5432/tcp

The first belongs to a worktree that no longer exists. It publishes no port, so nothing can reach it — but it is enough to make every make target refuse. It also holds wattroom_wt_mic_camera_selection_ui_70d898_8351, which means the stranded databases from #2105 are spread across two servers rather than one.

The confusing part, worth writing down

Only make breaks. A bare go test with a DSN pointing at localhost:5432 keeps working, because exactly one of the containers publishes the port. So the symptom is "make stopped working but my tests pass", which points at the Makefile rather than at docker.

What to do

worktree-gc (#2098) is the natural home: bring the worktree's compose project down before removing the directory, for the same reason it now drops the databases first — afterwards there is no docker-compose.yml path to address the project by.

Whether it should also offer to stop a container whose worktree is already gone is the open question. The name embeds the worktree's directory, so matching is possible, but the same caution as #2105's stranded databases applies: another clone on the same machine looks identical from here. Reporting it and printing the docker rm -f may be the whole answer.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinginfraCI, deploy, tooling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions