Files
mtusi2026lab3/evidence/idempotency/replay-after-restart.md
T
ricoromaandClaude Opus 5.5 c5840bfaa8 docs: add idempotency and X-Instance-Id evidence to the report
- evidence for replay, conflict, replay through a new API process and
  after restarting API and storages, keys table, key race,
  X-Instance-Id in responses and logs, explicit and invalid
  instance_id and key TTL, test runs
- stand evidence: make wipe_data leaves the lab 2 volume intact, build
  from a fresh git clone passes smoke, bench restore stage sends with
  Idempotency-Key
- REPORT.md: X-Instance-Id, idempotency design, IDEMPOTENCY_TTL_SECONDS
  mapping, limitations and evidence rows
- tasks.md: mark the change tasks done, add follow-ups from verify

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 17:08:47 +03:00

37 lines
2.3 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.
# Повтор через новый процесс API
| | |
|---|---|
| Спеки | `idempotency` «Повтор после рестарта API» (исключение в `student-tests/spec_coverage.py`: тесты сервер не трогают) |
| Change | `instance-id-idempotency`, задача 9.1 |
| Дата | 2026-10-08 16:44:53–16:44:59 UTC |
| Commit | `af4bca0` |
| Стенд | `make run_docker`: проект `mtusi-lab3`, один контейнер api (образ `mtusi-messenger:lab3` из `af4bca0`), `127.0.0.1:8080`, без балансировщика |
| Хост | Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7,7 GiB RAM; лимиты контейнерам не задавались |
| Клиент | тот же разовый stdlib-скрипт, что в `replay.md`; токен alice не печатается |
Сообщение отправлено с ключом K (`replay.md`, первая строка). Затем API
заменён новым контейнером — другой процесс, другой hostname, — и тот же
клиент с тем же токеном повторил запрос.
```text
$ docker compose up -d --force-recreate api
```
| | Контейнер api | `StartedAt` | `X-Instance-Id` |
|---|---|---|---|
| до | `7956d7741a15` | 2026-10-08T16:44:54.716801044Z | `7956d7741a15` |
| после | `9b306176dcf4` | 2026-10-08T16:44:58.448549171Z | `9b306176dcf4` |
Повтор через новый процесс: `201`, JSON совпал с ответом первой
отправки целиком (тот же `id` и `created_at` до микросекунды):
```json
{"id": "090a896a-dc91-4010-8332-3f6d3d97f858", "chat_id": "4b84e4e3-4a26-40d7-89a5-632d19bbbc31", "sender_id": "536d7a14-d489-45b9-b3e3-0f92822b3d62", "text": "Привет из evidence", "created_at": "2026-10-08T16:44:53.810923Z"}
```
Сообщений с этим текстом в истории чата — 1. Ключ и результат хранятся
в PostgreSQL (`idempotency_keys`, `keys-table.md`), а не в памяти
процесса: новый процесс нашёл их и вернул сохранённое сообщение. Сессия
тоже в PostgreSQL — повторный вход не понадобился.