# Регрессия change `graceful-failover` на итоговом commit | | | |---|---| | Спеки | все основные спеки через `make student_test` и сверку покрытия; `load-balancing` «Отказ одной реплики», «Failover hook»; `data-storage` «Данные переживают рестарт»; `load-benchmark` «Фиксированный стенд» — «Одна реплика за балансировщиком», «Лимиты в паспорте», «Профиль отказа реплик» — «Быстрый профиль»; `graceful-shutdown` «Простаивающие соединения закрывает балансировщик» — «Клиенты молчат после всплеска» | | Change | `graceful-failover`, задачи 5.2 и 7.1 | | Дата | 2026-10-10 20:21:28–20:41:38 UTC; часть C (verify) — 21:07:00–21:07:02 UTC | | Commit | `459f84c` (рабочий стенд пересоздан с него: `make down`, `make run_docker`); часть C — `12783aa` (код приложения тот же) | | Стенд | часть A — рабочий `mtusi-lab3`: HAProxy на `127.0.0.1:8080`, `api` × 2; часть B — свои стенды (`test_isolated`, `<рабочий>-failures`, `mtusi-bench`) | | Хост | Docker Desktop 29.8.2, macOS arm64; ВМ Docker: 12 CPU, 7,7 GiB RAM; питание от сети. Самопроверки, не замеры: хост не готовился, рабочий стенд в части B работал | Каждая команда запускалась скриптом подряд, со строкой `### <время> $ <команда>` и кодом выхода. Ниже — итоговые строки каждой команды; промежуточные строки pytest (`PASSED` по тестам) опущены. ## Часть A: рабочий стенд через LB ```text ### 2026-10-10T20:21:28Z $ git log --oneline -1 459f84c feat: coordinate timeout chain and add failover load profile ### 2026-10-10T20:21:28Z $ make down → exit 0 ### 2026-10-10T20:21:29Z $ make run_docker → exit 0 ### 2026-10-10T20:21:36Z $ docker compose ps --format {{.Name}} {{.Status}} mtusi-lab3-api-1 Up 2 seconds (healthy) mtusi-lab3-api-2 Up 2 seconds (healthy) mtusi-lab3-haproxy-1 Up 2 seconds (healthy) mtusi-lab3-postgres-1 Up 5 seconds (healthy) mtusi-lab3-valkey-1 Up 5 seconds (healthy) ### 2026-10-10T20:21:36Z $ make test PASS: lab3 public API scenario; infrastructure and grading evidence remain separate. ### exit 0 ### 2026-10-10T20:21:37Z $ make student_test BASE_URL=http://localhost:8080 EXPECT_REPLICAS=2 uv run pytest ===================== 131 passed, 15 deselected in 24.67s ====================== ### exit 0 ### 2026-10-10T20:22:02Z $ make test-persistence ACTION_SCRIPT=scripts/restart.sh PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence. ### exit 0 ### 2026-10-10T20:22:09Z $ STOP_ONE_LOG=… make test-failover ACTION_SCRIPT=scripts/stop-one.sh {"observed_instances_before": 2, "successful_writes": 112, "failed_attempts": 0, "first_recovery_seconds": 1.616} PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence. ### exit 0 $ docker compose ps -a --format '{{.Name}} {{.ID}} {{.Status}}' mtusi-lab3-api-1 abd10a328015 Up 17 seconds (healthy) mtusi-lab3-api-2 bbc91284862a Exited (0) 14 seconds ago mtusi-lab3-haproxy-1 7becd62a1dec Up 17 seconds (healthy) mtusi-lab3-migrate-1 61ab4faaaad5 Exited (0) 18 seconds ago mtusi-lab3-postgres-1 89ed518771ed Up 21 seconds (healthy) mtusi-lab3-valkey-1 23532d4ffe4c Up 21 seconds (healthy) $ cat 2026-10-10T20:22:10Z TARGET_INSTANCE_ID=bbc91284862a container=bbc91284862aeadd3a3e2be77d8b8de16716ec61271d1c32e94312e4f47a5690 mode=stop ### 2026-10-10T20:22:25Z $ make replicas → exit 0 $ curl -s -o /dev/null http://127.0.0.1:8080/health/live # сдвиг очереди round-robin ### 2026-10-10T20:22:28Z $ STOP_MODE=kill STOP_ONE_LOG=… make test-failover ACTION_SCRIPT=scripts/stop-one.sh {"observed_instances_before": 2, "successful_writes": 116, "failed_attempts": 1, "first_recovery_seconds": 0.227} PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence. ### exit 0 $ docker compose ps -a --format '{{.Name}} {{.ID}} {{.Status}}' mtusi-lab3-api-1 abd10a328015 Exited (137) 15 seconds ago mtusi-lab3-api-2 bbc91284862a Up 19 seconds (healthy) … $ cat 2026-10-10T20:22:10Z TARGET_INSTANCE_ID=bbc91284862a container=bbc91284862aeadd3a3e2be77d8b8de16716ec61271d1c32e94312e4f47a5690 mode=stop 2026-10-10T20:22:29Z TARGET_INSTANCE_ID=abd10a328015 container=abd10a3280150e87d47e944c83f1ea541b7a7c4c368f6a4f385834be8266b24f mode=kill ### 2026-10-10T20:22:44Z $ make replicas → exit 0 ### 2026-10-10T20:22:46Z $ python3 .claude/skills/run-mtusi-messenger/driver.py --port 8080 idle-conns replicas hold no connections 10.1 s after the last request (replica keep-alive 60 s): closed by LB ### exit 0 ### 2026-10-10T20:22:58Z $ python3 .claude/skills/run-mtusi-messenger/driver.py --port 8080 hang-key chat history: 200, 1 message(s) with the probe text; all replicas UP in LB: True ### exit 0 ``` - `make test-failover` в обоих режимах — `PASS`, остановлена именно реплика `TARGET_INSTANCE_ID` (строка hook = ID контейнера в `docker compose ps -a`), сначала `api-2` (`stop`, код выхода 0), затем `api-1` (`kill`, код 137). В режиме `kill` одна неудачная попытка — запрос в полёте на убитой реплике; тест повторил его с тем же ключом, дублей нет. Подробный разбор режимов прежний — `../failover/test-failover.md`, `../failover/test-failover-kill.md` (commit `a4ca9ef`). - Полные выводы `idle-conns` и `hang-key` — `../failover/keep-alive.md` и `../failover/hung-key.md`. ## Часть B: свои стенды ```text ### 2026-10-10T20:32:02Z $ make test_isolated PASS: lab3 public API scenario; infrastructure and grading evidence remain separate. student-tests/test_idempotency.py::test_replay_on_other_replica SKIPPED student-tests/test_load_balancing.py::test_one_session_on_several_replicas SKIPPED student-tests/test_load_balancing.py::test_write_visible_through_other_replica SKIPPED student-tests/test_race.py::test_same_key_through_replicas SKIPPED (...) coverage: 135 scenarios in 11 specs, 123 tested (16 by make failure_checks), 12 excluded =========== 127 passed, 4 skipped, 15 deselected in 63.39s (0:01:03) =========== ### exit 0 ### 2026-10-10T20:33:14Z $ make failure_checks ===================== 15 passed, 131 deselected in 45.31s ====================== ### exit 0 ### 2026-10-10T20:34:08Z $ make bench_quick [00:00:01] size 1k (1/3): start [00:00:32] run 1/18 read 1k c=1 r1: 594 rps p50 1.569 p95 1.957 p99 2.651 ms cpu 0.827 db 0.117 rss 92.7 MiB err 0 ~7m04s left … [00:03:22] run 18/18 write 10k c=16 r1: 592 rps p50 24.604 p95 44.225 p99 72.633 ms cpu 1.007 db 0.246 rss 93.5 MiB err 0 ~1m00s left [00:03:26] complete: 18/18 runs, results in evidence/bench/quick-20261010T203408Z ### exit 0 ### 2026-10-10T20:37:35Z $ make bench_restore_quick [00:00:29] size 1k: backup 0.6 MiB in 0.11s during 1000 writes (0 failed) [00:00:34] size 1k: restored 4586 of 5501 messages (915 lost after the snapshot), restore 0.08s, ANALYZE 0.10s, API 0.84s, RTO 2.0s; stale chat GET 200 POST 500, after FLUSHALL 404 [00:01:08] size 5k: backup 1.1 MiB in 0.14s during 1000 writes (0 failed) [00:01:14] size 5k: restored 8604 of 9501 messages (897 lost after the snapshot), restore 0.10s, ANALYZE 0.12s, API 2.59s, RTO 3.79s; stale chat GET 200 POST 500, after FLUSHALL 404 [00:01:58] size 10k: backup 1.7 MiB in 0.17s during 1000 writes (0 failed) [00:02:03] size 10k: restored 13612 of 14501 messages (889 lost after the snapshot), restore 0.12s, ANALYZE 0.13s, API 0.85s, RTO 2.07s; stale chat GET 200 POST 500, after FLUSHALL 404 [00:02:04] complete: 0/0 runs, results in evidence/bench/quick-restore-20261010T203735Z ### exit 0 ### 2026-10-10T20:39:41Z $ make bench_failover_quick [00:00:38] phase 01-stop-r1: LB out 2.18 s (MAINT, bound 2.5 s), errors 1 [502:1], recovery 0 s, back in LB 1.81 s, errors after 0, 4601 ok of 4602; retried 0, messages 2301 = keys 2301 [00:01:04] phase 02-stop-r2: LB out 1.83 s (DOWN, bound 2.5 s), errors 0 [], recovery 0 s, back in LB 0.78 s, errors after 0, 4600 ok of 4600; retried 0, messages 4601 = keys 4601 [00:01:30] phase 03-kill-r1: LB out 1.02 s (DOWN, bound 2.5 s), errors 2 [502:2], recovery 0 s, back in LB 0.97 s, errors after 0, 4600 ok of 4602; retried 0, messages 6902 = keys 6902 [00:01:56] phase 04-kill-r2: LB out 1.03 s (DOWN, bound 2.5 s), errors 2 [502:2], recovery 0 s, back in LB 0.97 s, errors after 0, 4600 ok of 4602; retried 1, messages 9203 = keys 9203 [00:01:57] complete: 4/4 runs, results in evidence/failover/quick-failover-20261010T203941Z ### exit 0 ``` - `make test_isolated` — один контейнер API без LB (`EXPECT_REPLICAS=1`): четыре теста реплик пропущены с причиной, остальные прошли, сверка покрытия сходится — новые сценарии `graceful-failover` лежат в спеках вне сверки (`load-balancing`, `graceful-shutdown`, `load-benchmark`, `service-configuration`). - `make bench_quick` и `make bench_restore_quick` — профили лабы 2 на стенде с HAProxy и одной репликой: код 0. В паспорте `quick-20261010T203408Z` — `limits.api_replicas` 1, `limits.haproxy` 1 CPU / 256 МиБ без портов, `stand.haproxy` — образ и версия HAProxy 3.4.6. Ответ `POST 500` на чат после backup до `FLUSHALL` — прежнее поведение трека 2 (`bench-restore-quick.md`), не регрессия. - `make bench_failover_quick` — код 0, четыре фазы, сверка записей сошлась в каждой. В фазе `01-stop-r1` один 502 — гонка keep-alive при SIGTERM (design, решение 3; `../failover/keep-alive.md`), доля успешных в каждой секунде выше 99 %. - В паспортах самопроверок части B `dirty: true`: в рабочем дереве в это время лежал неотслеживаемый черновик evidence. Код — `459f84c`. ## Часть C: правки verify (`12783aa`) Правки verify (design, решение 10) не меняют приложение и действующую конфигурацию LB: `git diff 459f84c 12783aa -- src docker-compose.yml Dockerfile` пуст, в `haproxy.cfg` — только комментарий (`haproxy -c` в закреплённом образе — код 0). Профили `bench` не перезапускались: их код не менялся, кроме `compare.py`. Команды драйвера — в `../failover/keep-alive.md` и `../failover/hung-key.md`. ```text ### 2026-10-10T21:07:00Z $ uv run python bench/compare.py --before quick-20261010T155358Z --after quick-20261010T203408Z compare failed: label quick-20261010T155358Z was measured without the load balancer (before change graceful-failover): different methodology ### exit 1 ### 2026-10-10T21:07:01Z $ uv run python bench/compare.py --before quick-20261010T203408Z --after quick-20261010T203408Z saved to evidence/compare/quick-20261010T203408Z__quick-20261010T203408Z.md ### exit 0 ### 2026-10-10T21:07:01Z $ make test PASS: lab3 public API scenario; infrastructure and grading evidence remain separate. ``` - `quick-20261010T155358Z` — самопроверка до change, стенд без LB (в паспорте нет `limits.haproxy` и `limits.api_replicas`), сравнение с меткой стенда с LB — отказ. Раньше команда сравнила бы их и только предупредила «записан только в одной метке». Две метки стенда с LB сравниваются как прежде (сравнение пробной метки с собой, файл результата удалён, `evidence/compare/*quick-*` — в `.gitignore`). - `make lint`, `make check`, `openspec validate graceful-failover --strict` — без ошибок.