Лаба 3: Nginx LB, 2 реплики API и общая идемпотентность (оценка 4)

Переиспользован стек lab2 (Postgres/Redis/Argon2id). Добавлены: Nginx
балансировщик перед api1/api2, общая идемпотентность POST-сообщений
(idempotency_keys + advisory-lock сериализация в Postgres), explicit
stop-one/restart hooks. make test/test-persistence/test-failover/validate
зелёные для обеих реплик; найдены и исправлены гонка миграций и гонка
рестарта Nginx/DNS — см. REPORT.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 00:35:53 +03:00
co-authored by Claude Sonnet 5
parent 0ab3a341aa
commit 2f1cf3afac
18 changed files with 1093 additions and 15 deletions
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
set -eu
# Restarts the whole stack (LB, both API replicas, PostgreSQL, Redis) without touching volumes.
cd "$(dirname "$0")/.."
# Sequenced on purpose: nginx resolves upstream hostnames only at startup, so it
# must come back strictly after api1/api2 are reachable again, not in parallel.
docker compose restart postgres redis
docker compose restart api1 api2
docker compose restart lb
exit 0
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
set -eu
# Stops exactly the API replica identified by TARGET_INSTANCE_ID (api1 or api2),
# leaving it stopped. The other replica keeps serving traffic through the LB.
cd "$(dirname "$0")/.."
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID must be set by the test harness}"
case "$TARGET_INSTANCE_ID" in
api1|api2) ;;
*) echo "unknown instance id: $TARGET_INSTANCE_ID" >&2; exit 1 ;;
esac
docker compose stop "$TARGET_INSTANCE_ID"
exit 0