Skip to content

Commit 2c9bc0f

Browse files
author
Shane Wall
committed
Updates to the demo:
demo/postgres-survive-kill9/Dockerfile: switched to the glibc Postgres base and removed the unsupported --compression flag; kept the -- separator so DiffKeeper wraps the upstream entrypoint correctly. demo/postgres-survive-kill9/docker-compose.yml: escaped env vars inside the loader command, made pgbench init idempotent (only initializes if tables are missing), and keeps the workload loop running without wiping data on restart. Run notes from this machine: Stack comes up cleanly now; pgbench workload loads and runs. A manual kill (docker kill -s KILL …) followed by docker compose up -d postgres brings Postgres back with the pgbench counts continuing upward (baseline 504 → after restart 3201). Compose won’t auto-restart the container after a manual docker kill because restart policies ignore explicit stops; add docker compose up -d postgres (or docker compose restart postgres) after the kill in your script to make it pass.
1 parent bfc6d49 commit 2c9bc0f

5 files changed

Lines changed: 19 additions & 12 deletions

File tree

demo/postgres-survive-kill9/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM ghcr.io/saworbit/diffkeeper:latest AS diffkeeper
22

3-
FROM postgres:16-alpine
3+
# Debian-based Postgres to match the glibc-linked agent binary
4+
FROM postgres:16
45

56
# Pull the exact agent binary we ship so the demo matches production
67
COPY --from=diffkeeper /usr/local/bin/diffkeeper /usr/local/bin/diffkeeper
@@ -13,7 +14,6 @@ ENTRYPOINT ["diffkeeper", \
1314
"--state-dir=/var/lib/postgresql/data", \
1415
"--store=/deltas/diffkeeper.bolt", \
1516
"--snapshot-interval=15", \
16-
"--compression=zstd", \
1717
"--metrics-addr=:9911", \
1818
"--", \
1919
"docker-entrypoint.sh"]

demo/postgres-survive-kill9/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ docker compose up -d
1313
Linux/Mac:
1414

1515
```bash
16-
./chaos.sh
16+
./chaos.sh # restarts the container after each kill
1717
```
1818

1919
Windows:
2020

2121
```bat
22-
chaos.bat
22+
chaos.bat # restarts the container after each kill
2323
```
2424

2525
## Verify zero data loss

demo/postgres-survive-kill9/chaos.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ set /a delay=%RANDOM% %% 8 + 3
1717
timeout /t %delay% >nul
1818
echo %date% %time% sending kill -9 to %target%
1919
docker kill -s KILL %target% >nul 2>&1
20+
rem Ensure the container comes back up (restart policies sometimes skip manual kills)
21+
docker compose up -d postgres >nul 2>&1
2022
goto loop

demo/postgres-survive-kill9/chaos.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ while true; do
1515
fi
1616
echo "$(date -Iseconds) Sending kill -9 to ${target}"
1717
docker kill -s KILL "$target" >/dev/null 2>&1 || true
18+
# Ensure the container comes back up (restart policies sometimes skip manual kills)
19+
docker compose up -d postgres >/dev/null 2>&1 || true
1820
done

demo/postgres-survive-kill9/docker-compose.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
POSTGRES_DB: bench
1313

1414
loader:
15-
image: postgres:16-alpine
15+
image: postgres:16
1616
restart: unless-stopped
1717
depends_on:
1818
- postgres
@@ -21,16 +21,19 @@ services:
2121
PGUSER: postgres
2222
PGPASSWORD: postgres
2323
PGDATABASE: bench
24-
entrypoint: /bin/sh
24+
entrypoint: /bin/bash
2525
command: >
2626
-c "
27-
set -e;
28-
apk add --no-cache postgresql-client postgresql-contrib;
29-
until pg_isready -h "$PGHOST" -U "$PGUSER"; do sleep 1; done;
30-
createdb "$PGDATABASE" || true;
31-
pgbench -i "$PGDATABASE" || true;
27+
set -euo pipefail;
28+
apt-get update -qq;
29+
apt-get install -y -qq postgresql-client postgresql-contrib;
30+
until pg_isready -h "$$PGHOST" -U "$$PGUSER"; do sleep 1; done;
31+
createdb "$$PGDATABASE" || true;
32+
if ! psql -h "$$PGHOST" -U "$$PGUSER" -d "$$PGDATABASE" -tAc \"SELECT 1 FROM pg_tables WHERE tablename='pgbench_accounts'\" | grep -q 1; then
33+
pgbench -i "$$PGDATABASE";
34+
fi;
3235
while true; do
33-
pgbench -c 4 -j 2 -t 1000 "$PGDATABASE" || true;
36+
pgbench -c 4 -j 2 -t 1000 "$$PGDATABASE" || true;
3437
sleep 0.5;
3538
done
3639
"

0 commit comments

Comments
 (0)