fix: pgtest left an anonymous volume behind on every run #175
Reference in New Issue
Block a user
Delete Branch "fix/pgtest-volume-leak"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
go test ./...leaked one Docker volume per test package.pgtest.Maintore its throwaway container down withdocker rm -f— no-v. Thepostgres:17-alpineimage declares aVOLUMEfor/var/lib/postgresql/data, and an explicitrmwithout-vorphans that anonymous volume even though the container was created with--rm.Found in passing: a 13-hour-old orphaned pgtest container (AutoRemove,
fsync=off, one mount) still running from a killed test binary — the same leak's other half. Removed on the dev machine.Change
backend/internal/pgtest/pgtest.go:-von all threedocker rm -fteardown sites (Main's defer, and both error paths instart).AGENTS.md: cleanup expectation under Commands —docker compose down -vfor a stack,docker rm -f -vfor a hand-run container, then checkdocker volume lsanddocker system df. Explicitly out of bounds: removing the user'spostgres-datavolume, or a blanketdocker system pruneof their images and build cache.Verification
docker volume lssnapshot diffed across a real./internal/storerun: no new volumes,docker system dfreports 0 local volumes.