Repository navigation
Conversation
The smoke tests of publish-release-images and release-tooling-validation waited for PostgreSQL with pg_isready over the Unix socket. The postgres image runs a temporary server during its own setup that listens on the Unix socket only, so the wait could pass against it and the fail-closed check after it could then land in the restart window and fail the job with "PG not ready" (#501). Both jobs now call pg_isready with -h 127.0.0.1. The temporary server does not listen on TCP, so the check answers only when the real server is up. scripts/test-pg-readiness-race.sh starts one postgres container and asks it both ways, back to back, from before it is up until the real server answers. It fails when the socket check answers accepting while the TCP check does not. The new CI job pg-readiness-check runs it. It also counts the moments of the race window, which the old form of the check was exposed to. Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 519810a46d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| [ "$s" = 1 ] && socket_sees=$((socket_sees + 1)) | ||
| [ "$t" = 1 ] && tcp_sees=$((tcp_sees + 1)) | ||
| if [ "$s" = 1 ] && [ "$t" = 0 ]; then race_moments=$((race_moments + 1)); fi | ||
| if [ "$t" = 1 ] && [ "$s" = 0 ]; then tcp_first=$((tcp_first + 1)); fi |
There was a problem hiding this comment.
Recheck the socket before treating TCP success as premature
If PostgreSQL finishes starting between the socket probe on line 35 and the TCP probe on line 36, the first probe legitimately fails and the second succeeds. This condition nevertheless increments tcp_first, causing the script to exit with failure even after twenty successful TCP checks. Consequently, the new pg-readiness-check job in .github/workflows/ci.yml can intermittently fail healthy CI runs. A simulated normal startup with only the first probe failing reproduces this outcome. Recheck the socket after TCP succeeds, or use an independent startup-state assertion, rather than interpreting sequential observations as simultaneous.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🤖 AI Code Review — 💬 Needs discussion
Confidence: medium · Findings: 1
AI judgment: NEEDS DISCUSSION · Evidence: COMPLETE · Authority: advisory
Evidence complete · 2/2 changed files accounted for
Key issues
- [HIGH] Regression test fails spuriously when the real server starts between its socket and TCP probes (
scripts/test-pg-readiness-race.sh) 🔮
🔮 Devil's Advocate (2 turns): 1 upheld
GitWire AI Review Gate (bundle-driven v2) · Structured schema · Scope-validated · Devil's Advocate · AI recommendation — maintainers and repository policy retain authority
| echo "first TCP accept after about ${first_tcp_s}s" | ||
| echo "moments with socket=yes and TCP=no (the race window): $race_moments" | ||
| echo "moments with TCP=yes and socket=no: $tcp_first" | ||
| if [ "$tcp_first" -ne 0 ]; then echo "FAIL: the TCP check passed where the socket check did not"; exit 1; fi |
There was a problem hiding this comment.
[HIGH] Regression test fails spuriously when the real server starts between its socket and TCP probes
Each loop iteration runs the socket check first and the TCP check immediately after, then fails the whole run if any single iteration recorded t=1 && s=0 (tcp_first, enforced at the if [ "$tcp_first" -ne 0 ] ... exit 1 line). That condition also occurs at the normal, expected startup transition: if the real server becomes accepting in the gap between the socket probe and the TCP probe of the same iteration, s=0 and t=1 are recorded and the script exits 1, failing the new pg-readiness-check job even though the fix is working exactly as intended. With two docker exec invocations per iteration (~50-100 ms each), the socket-to-TCP gap covers a sizable fraction of each cycle, so the per-run flake probability is plausibly tens of percent - i.e., the patch introduces a new flaky CI job in a PR whose whole purpose is removing CI flakiness. The assertion is also structurally unable to detect the regression it targets: if the temporary server ever listened on TCP it would listen on the socket too (s=1, t=1), so tcp_first would stay 0; the only realistic producer of t=1 && s=0 is benign timing skew. Suggested fix: re-probe before declaring failure. E.g. on t=1 && s=0, sleep 0.2 and re-run the socket check; count tcp_first only if the re-check also fails. A genuine TCP-only temporary server would still fail the socket re-check, while the normal transition would not, eliminating the spurious exit.
|
Both reviews on this pull request found the same defect in The fix is on a new branch, because a branch cannot be updated here. The successor keeps the workflow change byte for byte and replaces the criterion of the test with one that holds: once the TCP check has answered accepting, it has to answer accepting in every later probe. A check that had answered against the temporary server stops answering when that server stops. This pull request is closed as superseded, unmerged. Its branch and its record stay. |
Status
The fix of #501, as the review asked: a small change and an independent regression test. Created for review. The merge needs the maintainer's approval.
What failed
The smoke tests of
publish-release-imagesandrelease-tooling-validationwaited for PostgreSQL withpg_isreadyover the Unix socket. The postgres image runs a temporary server during its own setup that listens on the Unix socket only. So the wait could pass against that server, and the fail-closed check after it could land in the restart window and fail the job. Seen once, on #499:PG not ready, after a step of five seconds.The change
Both jobs now call
pg_isreadywith-h 127.0.0.1. The temporary server does not listen on TCP, so the check answers only when the real server is up..github/workflows/ci.yml, jobpublish-release-images-h 127.0.0.1.github/workflows/ci.yml, jobrelease-tooling-validationscripts/test-pg-readiness-race.sh.github/workflows/ci.yml, jobpg-readiness-checkThe
--health-cmdof the service container indocker-build-appis left as it is. A Docker health check is asked again until it passes, so it does not depend on one answer.The regression test
scripts/test-pg-readiness-race.shstarts onepostgres:16-alpinecontainer and asks it both ways, back to back: the socket check, then the TCP check. It does so from before the container is up until the real server has answered twenty times in a row.Verification
Manual CI run on this branch, commit
519810a: https://github.com/Octo-Lex/GitWire/actions/runs/45123434472. All 17 jobs passed, the new one included;publish-release-imagesis skipped on a manual run by design.pg-readiness-check:postgres:16-alpineThe test did what it is for. It caught the race window in a real PostgreSQL container, once in 35 probes, and it showed that the TCP form does not answer in that window. One probe is thin evidence for how often the window is hit: the run was a single one.
The rest of the run, with the two smoke tests on the TCP check:
release-tooling-validationpassed on the first attempt.Not covered