-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdurability.sh
More file actions
executable file
·24 lines (23 loc) · 1.39 KB
/
Copy pathdurability.sh
File metadata and controls
executable file
·24 lines (23 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
# What the primary's durability setting alone buys the replica reader.
# One config at a time, nothing else running: 60s of pgbench for the write
# cost, then 600 write-then-read-replica rounds for the staleness.
set -euo pipefail
export PGPASSWORD=postgres
cd "$(dirname "$0")"
P() { psql -h localhost -p 55432 -U postgres -X -qAt "$@"; }
docker exec wf-primary pgbench -U postgres -q -i -s 20 postgres >/dev/null 2>&1
for cfg in ":on:async" "walreceiver:on:sync-flush" "walreceiver:remote_apply:remote-apply"; do
IFS=: read -r names sc tag <<< "$cfg"
P -c "ALTER SYSTEM SET synchronous_standby_names='$names'" >/dev/null
P -c "ALTER SYSTEM SET synchronous_commit='$sc'" >/dev/null
P -c "SELECT pg_reload_conf()" >/dev/null; sleep 2
echo "--- $tag: synchronous_commit=$(P -c 'SHOW synchronous_commit') names='$(P -c 'SHOW synchronous_standby_names')' sync_state=$(P -c 'SELECT coalesce(sync_state,'"'"'-'"'"') FROM pg_stat_replication')"
echo -n " write cost: "
docker exec wf-primary pgbench -U postgres -c 8 -j 4 -T 60 -N postgres 2>&1 | grep -E '^tps'
P -c "TRUNCATE messages" >/dev/null
(cd bench && GOFLAGS=-mod=mod go run . -mode replica -n 600 -c 8 -label "durability-$tag") >>"results-durability.jsonl"
done
P -c "ALTER SYSTEM SET synchronous_standby_names=''" >/dev/null
P -c "ALTER SYSTEM SET synchronous_commit='on'" >/dev/null
P -c "SELECT pg_reload_conf()" >/dev/null