Repository navigation
fix(docker): don't let a stale postmaster.pid fake a PostgreSQL start - #25
Merged
Merged
Conversation
The Docker smoke job on dev fails at "re-created container on the same volume": pg_ctl reports "server started" and psql then finds no socket. `docker rm -f` (like any kill, OOM or node loss) leaves postmaster.pid in the data volume. Since the entrypoint switched from `su` to `setpriv`, every boot after the first runs the same process sequence, so the new postmaster gets the same PID as the old one; when it also starts within two seconds of the old lock's start time (CI re-creates in ~1.4 s), `pg_ctl -w` accepts the stale file's "ready" line and returns before the server has finished crash recovery or created its socket. - Before starting, remove postmaster.pid when its PID is not a live postgres process in this container (nothing else runs PostgreSQL here). - After pg_ctl, wait for pg_isready on the socket (up to 60 s, then fail with a pointer to the log) before running psql. docker-smoke.sh now reproduces it deterministically: it records the postmaster PID of a normal boot, kills the container, plants a lock with that PID, a future start time and a "ready" status, and requires the next container to start. The pre-fix image fails that step with the CI error; the fixed image passes the whole smoke test.
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.
Fixes the Docker image smoke tests failure on dev (
re-created container on the same volume→pg_ctl: server started→psql: … No such file or directory).Cause:
docker rm -fleavespostmaster.pidin the volume. With thesetpriventrypoint, boots after the first run the same process sequence, so the new postmaster gets the same PID; if it starts within 2 s of the old lock's start time (CI re-creates in ~1.4 s),pg_ctl -wtrusts the stale "ready" line and returns before PostgreSQL has a socket.Fix: remove a lock whose PID is not a live postgres process in this container; then wait for
pg_isready(≤ 60 s) beforepsql.Test:
docker-smoke.shnow plants exactly that lock (recorded postmaster PID, future start time,ready) and requires the next container to start. Locally: the pre-fix image fails this step with the CI error; the fixed image passes the full smoke test.