Skip to content

Commit 8f0df8d

Browse files
author
Shane Wall
committed
ci-smoke.sh now:
Uses a helper to read the pgbench count. Adds a short settle delay and explicit CHECKPOINT, then re-reads a “stable baseline” before the kill. After restart, it polls for up to ~60s for the count to catch up (in case replay is finishing) before failing. The metrics check remains best-effort.
1 parent 43c1afc commit 8f0df8d

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,18 @@ wait_metrics || true
6161
baseline=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0")
6262
echo "Baseline transactions: ${baseline}"
6363

64-
# Flush durable state before the crash so WAL is on disk
64+
get_count() {
65+
docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null | tr -d '\r'
66+
}
67+
68+
# Give the workload a moment to settle and flush durable state
69+
sleep 2
6570
docker compose exec -T postgres psql -U postgres -d bench -c "CHECKPOINT;" >/dev/null
6671

72+
# Re-read after checkpoint to ensure a stable baseline
73+
baseline=$(get_count)
74+
echo "Stable baseline transactions: ${baseline}"
75+
6776
docker compose kill -s KILL postgres
6877

6978
echo "Waiting for Postgres to restart..."
@@ -72,7 +81,17 @@ wait_pg
7281
wait_pgbench_tables
7382
wait_metrics || true
7483

75-
after=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0")
84+
after=$(get_count)
85+
86+
# Allow a short window for replay to catch up before failing hard
87+
for _ in {1..30}; do
88+
if (( after >= baseline )); then
89+
break
90+
fi
91+
sleep 2
92+
after=$(get_count)
93+
done
94+
7695
echo "Post-restart transactions: ${after}"
7796
if (( after < baseline )); then
7897
echo "Transaction count decreased after kill -9" >&2

0 commit comments

Comments
 (0)