The stand was recreated from a4ca9ef (make down, make run_docker) and
all evidence of the change was taken again on it: stand, distribution,
LB errors, test-persistence, test-failover for each replica (stop and
kill), stop-one refusals, make test and student_test through the LB,
test_isolated, failure_checks and bench self-checks.
New evidence closes scenarios verify found without proof: a real git
clone on non-default ports, a hung replica (docker pause: DOWN after
7.7 s, in-flight request 504), PostgreSQL outage behind the LB, replica
tests failing against one process, aborted responses via
driver.py kill-inflight. REPORT.md gets the corrected detection
formula, the measured cost of the 1 CPU limit for Argon2id and the new
rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6.0 KiB
make test-persistence через балансировщик
| Спеки | container-run «Данные переживают рестарт стенда» — «Рестарт hook-ом», «Публичная проверка сохранности»; sessions «Прежний токен после рестарта»; data-storage «Прежний пользователь после рестарта» |
| Change | replicas-lb, задачи 6.1 и 7.2 |
| Дата | 2026-10-10 15:47:53–15:48:02 UTC |
| Commit | a4ca9ef (стенд пересоздан с этого commit, stand.md) |
| Стенд | make run_docker: проект mtusi-lab3, HAProxy на 127.0.0.1:8080, api × 2; тест ходит через LB (BASE_URL по умолчанию) |
| Хост | Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7,7 GiB RAM; ноутбук от батареи |
scripts/restart.sh: stop haproxy api → restart postgres valkey →
up -d --wait postgres valkey → start api haproxy. Volumes не
удаляются, данные не наполняются заново. Тест создаёт данные и сессию,
вызывает hook, ждёт готовности через LB и проверяет те же данные
прежним токеном.
$ docker compose ps -a (до) # сервис, контейнер, ID, состояние, StartedAt
api /mtusi-lab3-api-1 3681880fc55f running exit=0 started=2026-10-10T15:46:57.553993883Z
api /mtusi-lab3-api-2 8100f940a5fa running exit=0 started=2026-10-10T15:46:57.498271675Z
haproxy /mtusi-lab3-haproxy-1 f878fd1fbf83 running exit=0 started=2026-10-10T15:45:09.060002041Z
migrate /mtusi-lab3-migrate-1 ffd98512d938 exited exit=0 started=2026-10-10T15:45:06.849190138Z
postgres /mtusi-lab3-postgres-1 da3195a39fcf running exit=0 started=2026-10-10T15:47:39.475441666Z
valkey /mtusi-lab3-valkey-1 169515bef463 running exit=0 started=2026-10-10T15:45:05.17644172Z
$ docker volume inspect -f "{{.Name}} {{.CreatedAt}}" mtusi-lab3_postgres_data
mtusi-lab3_postgres_data 2026-10-10T14:03:26Z
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8080"
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0 за 6.4 с
$ docker compose ps -a (после)
api /mtusi-lab3-api-1 3681880fc55f running exit=0 started=2026-10-10T15:47:58.49368355Z
api /mtusi-lab3-api-2 8100f940a5fa running exit=0 started=2026-10-10T15:47:58.4427858Z
haproxy /mtusi-lab3-haproxy-1 f878fd1fbf83 running exit=0 started=2026-10-10T15:47:58.560031592Z
migrate /mtusi-lab3-migrate-1 ffd98512d938 exited exit=0 started=2026-10-10T15:47:56.875245466Z
postgres /mtusi-lab3-postgres-1 da3195a39fcf running exit=0 started=2026-10-10T15:47:55.066928966Z
valkey /mtusi-lab3-valkey-1 169515bef463 running exit=0 started=2026-10-10T15:47:55.039021882Z
$ docker volume inspect -f "{{.Name}} {{.CreatedAt}}" mtusi-lab3_postgres_data
mtusi-lab3_postgres_data 2026-10-10T14:03:26Z
| Сервис | Контейнер | StartedAt до |
StartedAt после |
|---|---|---|---|
| haproxy | f878fd1fbf83 |
15:45:09.060 | 15:47:58.560 |
| api | 3681880fc55f |
15:46:57.554 | 15:47:58.494 |
| api | 8100f940a5fa |
15:46:57.498 | 15:47:58.443 |
| postgres | da3195a39fcf |
15:47:39.475 | 15:47:55.067 |
| valkey | 169515bef463 |
15:45:05.176 | 15:47:55.039 |
| migrate | ffd98512d938 |
15:45:06.849 | 15:47:56.875 (повторный прогон — no-op) |
Перезапущены LB, обе реплики API, Postgres и Valkey: те же ID
контейнеров, новое время старта у всех. Число реплик не изменилось,
volume Postgres — тот же (дата создания прежняя). Прежний StartedAt
Postgres — с проверки «PostgreSQL недоступен» (lb-errors.md), реплик —
с восстановления там же.
Журнал LB за окно рестарта
2026-10-10T15:47:54.367464715Z Proxy entry stopped (cumulated conns: FE: 395, BE: 0).
2026-10-10T15:47:58.632091217Z [NOTICE] (1) : Initializing new worker (8)
2026-10-10T15:47:58.649502301Z [NOTICE] (1) : Loading success.
2026-10-10T15:47:58.649965301Z api/api-1: IP changed from '(none)' to '172.30.0.5' by 'docker/dns'.
2026-10-10T15:47:58.649989217Z api/api-2: IP changed from '(none)' to '172.30.0.4' by 'DNS cache'.
2026-10-10T15:47:58.649991509Z Server api/api-1 ('api') is DOWN/READY (resolves again).
2026-10-10T15:47:58.649995759Z Server api/api-2 ('api') is DOWN/READY (resolves again).
2026-10-10T15:47:58.664751676Z 172.30.0.1:58888 [10/Oct/2026:15:47:58.664] entry api/<NOSRV> 0/-1/-1/-1/0 503 0 - - SC-- 1/1/0/0/0 0/0 "GET /health/ready HTTP/1.1"
2026-10-10T15:47:59.171462551Z 172.30.0.1:58902 [10/Oct/2026:15:47:59.171] entry api/<NOSRV> 0/-1/-1/-1/0 503 0 - - SC-- 1/1/0/0/0 0/0 "GET /health/ready HTTP/1.1"
2026-10-10T15:47:59.678091551Z 172.30.0.1:58906 [10/Oct/2026:15:47:59.677] entry api/<NOSRV> 0/-1/-1/-1/0 503 0 - - SC-- 1/1/0/0/0 0/0 "GET /health/ready HTTP/1.1"
2026-10-10T15:47:59.683768718Z Server api/api-1 is UP, reason: Layer7 check passed, code: 200, check duration: 33ms. 1 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
$ make instances # через 2 с после теста
3681880fc55f: 6
8100f940a5fa: 6
instances: 2
Пока реплики не прошли проверку /health/ready, тест получал 503 от
LB на /health/ready и ждал (до 90 с по tests/README.md). Реплики
начинают в DOWN (init-state down), поэтому запросы не уходили на
процесс, который ещё не слушает порт. Через 2 с после теста обе реплики
снова в распределении.