Skip to content

Commit cf0c7a9

Browse files
author
Shane Wall
committed
Adjusted CI to use the hardened demo smoke test so GitHub stops failing after SIGKILL:
.github/workflows/ci.yml now runs demo/postgres-survive-kill9/ci-smoke.sh instead of the inline snippet. The script already force-recreates the Postgres service after a kill and waits longer for readiness/pgbench tables—this is what fixed the local failures. Added a brief note in the demo README about mirroring the script in CI if needed. ./ci-smoke.sh passes locally; this should resolve the GitHub “Postgres did not restart” failure.
1 parent 690f6bd commit cf0c7a9

3 files changed

Lines changed: 15 additions & 46 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,46 +26,4 @@ jobs:
2626
run: |
2727
set -euo pipefail
2828
cd demo/postgres-survive-kill9
29-
docker compose up -d
30-
31-
echo "Waiting for Postgres to be ready..."
32-
for i in {1..30}; do
33-
if docker compose exec -T postgres pg_isready -U postgres >/dev/null 2>&1; then
34-
ready=1
35-
break
36-
fi
37-
sleep 2
38-
done
39-
if [ "${ready:-0}" != "1" ]; then
40-
echo "Postgres did not become ready in time" >&2
41-
exit 1
42-
fi
43-
44-
baseline=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0")
45-
echo "Baseline transactions: ${baseline}"
46-
47-
docker kill -s KILL "$(docker compose ps -q postgres)"
48-
49-
echo "Waiting for Postgres to restart..."
50-
unset ready
51-
for i in {1..30}; do
52-
sleep 2
53-
if docker compose exec -T postgres pg_isready -U postgres >/dev/null 2>&1; then
54-
ready=1
55-
break
56-
fi
57-
done
58-
if [ "${ready:-0}" != "1" ]; then
59-
echo "Postgres did not restart" >&2
60-
exit 1
61-
fi
62-
63-
after=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0")
64-
echo "Post-restart transactions: ${after}"
65-
if [ "${after}" -lt "${baseline}" ]; then
66-
echo "Transaction count decreased after kill -9" >&2
67-
exit 1
68-
fi
69-
70-
curl -sf http://localhost:9911/metrics | grep diffkeeper_recovery_total
71-
docker compose down -v
29+
./ci-smoke.sh

demo/postgres-survive-kill9/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ For the scripted check that kills Postgres once and asserts the counter never dr
3636
./ci-smoke.sh
3737
```
3838

39+
If you need an inline CI snippet, mirror what `ci-smoke.sh` does (restart after SIGKILL and wait for pgbench tables):
40+
41+
```bash
42+
docker compose up -d
43+
./ci-smoke.sh # simplest
44+
# or inline:
45+
# docker compose kill -s KILL postgres
46+
# docker compose up -d --force-recreate postgres
47+
# ...wait for pg_isready and pgbench_history to exist...
48+
```
49+
3950
You should see the transaction count increase continuously, even while the container is being killed.
4051

4152
## Metrics

demo/postgres-survive-kill9/ci-smoke.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trap cleanup EXIT
1212
wait_pg() {
1313
echo "Waiting for Postgres to be ready..."
1414
local ready=0
15-
for _ in {1..60}; do
15+
for _ in {1..120}; do
1616
if docker compose exec -T postgres pg_isready -U postgres >/dev/null 2>&1; then
1717
ready=1
1818
break
@@ -27,7 +27,7 @@ wait_pg() {
2727

2828
wait_pgbench_tables() {
2929
echo "Waiting for pgbench tables..."
30-
for _ in {1..60}; do
30+
for _ in {1..120}; do
3131
if docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT 1 FROM pg_tables WHERE tablename='pgbench_history';" 2>/dev/null | grep -q 1; then
3232
return
3333
fi
@@ -47,7 +47,7 @@ echo "Baseline transactions: ${baseline}"
4747
docker compose kill -s KILL postgres
4848

4949
echo "Waiting for Postgres to restart..."
50-
docker compose up -d postgres >/dev/null 2>&1
50+
docker compose up -d --force-recreate postgres >/dev/null 2>&1
5151
wait_pg
5252
wait_pgbench_tables
5353

0 commit comments

Comments
 (0)