File tree Expand file tree Collapse file tree
demo/postgres-survive-kill9 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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+
3950You should see the transaction count increase continuously, even while the container is being killed.
4051
4152## Metrics
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ trap cleanup EXIT
1212wait_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
2828wait_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}"
4747docker compose kill -s KILL postgres
4848
4949echo " 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
5151wait_pg
5252wait_pgbench_tables
5353
You can’t perform that action at this time.
0 commit comments