forked from mtusi2026/mtusi2026lab3
No failover run ever lost an answer, so the retry of an unconfirmed write was only covered in process. make retry-check holds the chat row with SELECT ... FOR UPDATE for 1.5 s (below lock_timeout), sends a message with a 0.5 s client timeout, finds the replica whose request waits on the lock in pg_stat_activity and then retries with the same key and text through the LB, once with that replica alive and once after docker kill. It checks the 201, a single copy with the id of the retry answer and, for the live replica, the 201 it logged without a client; created_at tells which attempt wrote the message. CI runs it. failover-each and rolling-update now record the database size and a docker stats snapshot in the background of the action, rolling-update names the tag and id of every image it replaces, and scaling.py writes started and the compose-up log marks in UTC with Z; the track README states that the recorded rows are host time (MSK) and what host-others.csv covers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
23 lines
953 B
Bash
Executable File
23 lines
953 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
service=${API_SERVICE:-api}
|
|
show() { docker inspect -f '{{.Config.Hostname}} image={{.Config.Image}}@{{slice .Image 7 19}}' "$1"; }
|
|
scripts/stand-usage.sh &
|
|
echo "$(date -u +%T) migrate once before the first replacement"
|
|
docker compose run --rm --no-deps -T migrate 2>&1
|
|
old=$(docker compose ps -q "$service")
|
|
count=$(printf '%s\n' "$old" | grep -c .)
|
|
for id in $old; do
|
|
running=$(docker compose ps -q "$service")
|
|
docker compose up -d --no-deps --no-recreate --wait --wait-timeout "${WAIT_TIMEOUT:-90}" --scale "$service=$((count + 1))" "$service" 2>&1
|
|
scripts/lb-wait.sh $((count + 1))
|
|
new=$(docker compose ps -q "$service" | grep -v -F "$running")
|
|
echo "$(date -u +%T) replace $(show "$id") -> $(show "$new")"
|
|
docker stop -t "${STOP_TIMEOUT:-7}" "$id" >/dev/null
|
|
docker rm "$id" >/dev/null
|
|
done
|
|
scripts/lb-wait.sh "$count"
|
|
wait
|
|
echo "$(date -u +%T) done: $count replicas replaced"
|