Files
mtusi2026lab3/evidence/idempotency/replay-after-storage-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

45 lines
2.9 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»: ключи переживают рестарт API и хранилищ с сохранёнными volumes (сценарий «Повтор после рестарта API» — `replay-after-restart.md`) |
| Change | `instance-id-idempotency`, доработка по `/opsx:verify` |
| Дата | 2026-10-10 14:00:36–14:00:42 UTC |
| Commit | `af4bca0` |
| Стенд | `make run_docker`: проект `mtusi-lab3`, один контейнер api (образ из чистого clone `af4bca0`, `evidence/tests/clean-clone.md`), `127.0.0.1:8080`, без балансировщика |
| Хост | Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7,7 GiB RAM; лимиты контейнерам не задавались |
| Клиент | разовый stdlib-скрипт, те же HTTP-хелперы, что в `replay.md`; токен и значение ключа не печатаются |
Сообщение отправлено с ключом K. Затем restart hook `make
test-persistence` перезапустил API, Postgres и Valkey без удаления
volumes, и тот же клиент с тем же токеном повторил запрос.
```text
send: 201 X-Instance-Id 4a75b36ce43d
message JSON: {"id": "86d920bd-4228-44e7-8a70-dac3b8b22074", "chat_id": "35d274b2-0261-415c-bc72-0bea526e03b8", "sender_id": "4eabf71d-a18c-47e4-82a7-968f15a1a6d9", "text": "Повтор после рестарта хранилищ", "created_at": "2026-10-10T14:00:37.039659Z"}
$ scripts/restart.sh
restart.sh exit 0 in 3.6 s
```
Перезапущены все три процесса — те же контейнеры, новый `StartedAt`:
| Сервис | Контейнер до | `StartedAt` до | Контейнер после | `StartedAt` после |
|---|---|---|---|---|
| api | `4a75b36ce43d` | 2026-10-10T14:00:12.228485168Z | `4a75b36ce43d` | 2026-10-10T14:00:40.903850376Z |
| postgres | `64f2b4291bc4` | 2026-10-10T13:58:10.807882751Z | `64f2b4291bc4` | 2026-10-10T14:00:38.018790333Z |
| valkey | `d988dceec6ee` | 2026-10-10T13:58:10.710317584Z | `d988dceec6ee` | 2026-10-10T14:00:38.058108958Z |
После рестарта:
```text
replay: 201 X-Instance-Id 4a75b36ce43d same JSON: True
other body: 409 conflict
messages in chat: 1 with this text: 1
```
Повтор с K и тем же телом — 201 и тот же `Message` целиком (тот же
`id` и `created_at`), другое тело с K — по-прежнему 409: ключ после
рестарта Postgres остался занятым. В чате одно сообщение. Ключи лежат в
том же volume Postgres, что и сообщения (`keys-table.md`), Valkey ключей
не хранит, а его кэш после рестарта пуст.