Files
mtusi2026lab4/evidence/attachments/failover.md
T
ricoromaandClaude Opus 5.5 8dc925e8ca docs: add attachments evidence and report
- re-capture coverage-exclusion evidence on the lab 4 stand: cache,
  auth storage, replay after API recreate, test-persistence,
  attachment-failover (stop, kill), attachment-storage
- green evidence/tests: student_test via LB, test_isolated,
  failure_checks; smoke, slow transfer, test-failover per replica
- bench_rollout label attachments: e1161f7 -> schema with attachments
  under load, no errors, messages = keys
- REPORT.md: attachments architecture, write order, defense answers,
  level 3/4 evidence rows, limitations; PLAN.md stage 2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 01:50:10 +03:00

101 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Вложение после остановки принявшей реплики
- Дата: 2026-10-20, 22:32:26–22:32:34 UTC.
- Commit: `d56b892` (код приложения — `116d8d3`, change `attachments`).
- Стенд: рабочий `mtusi-lab4` — HAProxy на `127.0.0.1:8080`, две
реплики API, PostgreSQL, Valkey, S3 (SeaweedFS).
- Исключение сверки покрытия `attachments` «Принявшая реплика
остановлена» (`student-tests/spec_coverage.py`); design change
`attachments`, решение 13.
Команда `driver.py attachment-failover` создаёт синтетических Алису,
Боба и Еву и чат Алисы и Боба, загружает `tests/fixtures/sample.png`
через LB (реплика A — `X-Instance-Id` ответа), отправляет сообщение со
ссылкой, вызывает `scripts/stop-one.sh` с `TARGET_INSTANCE_ID=A`, затем
Боб скачивает оригинал через LB, пока не ответит другая реплика, и
сверяет SHA-256; Ева получает 404. В `finally` — `make replicas` и
ожидание, пока LB снова видит обе реплики `UP`. Токены не печатаются.
## `--mode stop` (SIGTERM, graceful)
```
$ python3 .claude/skills/run-mtusi-messenger/driver.py --port 8080 attachment-failover --mode stop
mode: stop; fixture sample.png: 111817 bytes
docker compose ps (before):
NAME STATUS
mtusi-lab4-api-5 Up 18 seconds (healthy)
mtusi-lab4-api-6 Up 18 seconds (healthy)
mtusi-lab4-haproxy-1 Up 18 seconds (healthy)
mtusi-lab4-postgres-1 Up 43 seconds (healthy)
mtusi-lab4-s3-1 Up 28 seconds (healthy)
mtusi-lab4-valkey-1 Up 43 seconds (healthy)
sha256 uploaded: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
sha256 downloaded: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
docker compose ps (after):
NAME STATUS
mtusi-lab4-api-5 Up 1 second (healthy)
mtusi-lab4-api-6 Up 22 seconds (healthy)
mtusi-lab4-haproxy-1 Up 22 seconds (healthy)
mtusi-lab4-postgres-1 Up 47 seconds (healthy)
mtusi-lab4-s3-1 Up 32 seconds (healthy)
mtusi-lab4-valkey-1 Up 47 seconds (healthy)
step expected got x-instance-id
alice uploads 201 201 5f5d4ac50d9a
alice sends message 201 201 847ad74efd7c
stop-one.sh stop 0 0 5f5d4ac50d9a
bob downloads 200 200 847ad74efd7c
bob reads metadata 200 200 847ad74efd7c
eve reads metadata 404 404 847ad74efd7c
eve downloads 404 404 847ad74efd7c
make replicas 0 0
LB slots UP 2 2
PASS: accepted by 5f5d4ac50d9a, served by 847ad74efd7c after stop, sha256 matches, outsider gets 404
exit=0
```
## `--mode kill` (SIGKILL, отказ процесса)
```
$ python3 .claude/skills/run-mtusi-messenger/driver.py --port 8080 attachment-failover --mode kill
mode: kill; fixture sample.png: 111817 bytes
docker compose ps (before):
NAME STATUS
mtusi-lab4-api-5 Up 2 seconds (healthy)
mtusi-lab4-api-6 Up 22 seconds (healthy)
mtusi-lab4-haproxy-1 Up 22 seconds (healthy)
mtusi-lab4-postgres-1 Up 47 seconds (healthy)
mtusi-lab4-s3-1 Up 32 seconds (healthy)
mtusi-lab4-valkey-1 Up 47 seconds (healthy)
sha256 uploaded: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
sha256 downloaded: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
docker compose ps (after):
NAME STATUS
mtusi-lab4-api-5 Up 1 second (healthy)
mtusi-lab4-api-6 Up 25 seconds (healthy)
mtusi-lab4-haproxy-1 Up 25 seconds (healthy)
mtusi-lab4-postgres-1 Up 50 seconds (healthy)
mtusi-lab4-s3-1 Up 35 seconds (healthy)
mtusi-lab4-valkey-1 Up 50 seconds (healthy)
step expected got x-instance-id
alice uploads 201 201 5f5d4ac50d9a
alice sends message 201 201 847ad74efd7c
stop-one.sh kill 0 0 5f5d4ac50d9a
bob downloads 200 200 847ad74efd7c
bob reads metadata 200 200 847ad74efd7c
eve reads metadata 404 404 847ad74efd7c
eve downloads 404 404 847ad74efd7c
make replicas 0 0
LB slots UP 2 2
PASS: accepted by 5f5d4ac50d9a, served by 847ad74efd7c after kill, sha256 matches, outsider gets 404
exit=0
```
- В обоих режимах вложение принял `5f5d4ac50d9a` (`mtusi-lab4-api-5`),
его остановил `stop-one.sh`, а метаданные и оригинал отдал
`847ad74efd7c` (`mtusi-lab4-api-6`). SHA-256 скачанного совпал с
загруженным и с публичным fixture (`99ea7533…`).
- Посторонний получает 404 на метаданные и байты.
- После `make replicas` у `mtusi-lab4-api-5` новое время старта («Up 1
second»): остановленная реплика вернулась тем же контейнером, LB видит
обе `UP`.