Files
mtusi2026lab5/evidence/idempotency/replay-after-restart.md
T
ricoromaandClaude Opus 5.5 1373e7ddec docs: record exclusion evidence and move one-off probes into the driver
Adds worker-memory, freeze-sessions and freeze-lb driver commands, retakes
the evidence they produce, and fills the report header. src/ and bench/
are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 13:53:53 +03:00

65 lines
3.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
- Команды: `driver.py --port 8080 req POST /api/v1/chats/<chat>/messages --token <token> --data '{"text":"replay after restart"}' --key <ключ>`, `docker compose up -d --force-recreate api`, тот же `req` с тем же ключом и токеном, затем `req` с другим телом и `req GET` истории; скрипт шагов вне репозитория, сами шаги выше повторяются руками
- Дата: 2026-11-01, 10:34:20–10:34:29 UTC; коды выхода 0
- Commit: `9639aa1` (ветка `feat/track1-queue-overload`), код `src/` и `bench/` тот же, что на `5ee3257`; на рабочем дереве изменён только `.claude/skills/run-mtusi-messenger/driver.py`, команда `req` не менялась
- Стенд: проект compose `mtusi-lab5`, две реплики за HAProxy, собран `make run_docker` из `HEAD`; пользователь и чат синтетические
- Спек: `idempotency`, «Повтор после рестарта API» (исключение сверки покрытия: тесты сервер не трогают)
- Вывод обезличен: ключ заменён на `<key>`; токена и пароля в выводе нет
Итог: новые контейнеры обеих реплик (другие `id` и `StartedAt`), повтор — тот же 201 и тот же `Message` от реплики, которой при первой отправке не было (`7f8add826e12` → `97b8c4574c46`). В истории одно сообщение; другое тело с тем же ключом — 409. Сессия и ключ лежат в PostgreSQL, поэтому рестарт реплик на них не влияет. Compose пересоздал только реплики, зависимости (`migrate`, `s3-bootstrap`) лишь повторно запустил: их контейнеры прежние, PostgreSQL не перезапускался.
```text
--- before: api containers (name, id, StartedAt)
/mtusi-lab5-api-19 7f8add826e12 2026-11-01T10:28:40.349727095Z
/mtusi-lab5-api-20 5de01d9e5999 2026-11-01T10:28:40.064694511Z
--- first send
idempotency-key: <key>
201 x-request-id: 5fa5de5420954757bec0dc2e58bc271e x-instance-id: 7f8add826e12
{
"id": "838a93d9-cffc-4fbe-94e8-413f9ab191fa",
"chat_id": "f71fb930-1195-42af-b70e-b80661bc22f6",
"sender_id": "1b623133-e1dc-4fca-a8a2-50caf09536ed",
"text": "replay after restart",
"created_at": "2026-11-01T10:34:21.613999Z",
"attachment_ids": []
}
--- docker compose up -d --force-recreate api
Container mtusi-lab5-api-19 Recreated
Container mtusi-lab5-api-19 Started
Container mtusi-lab5-api-20 Recreated
Container mtusi-lab5-api-20 Started
Container mtusi-lab5-migrate-1 Started
Container mtusi-lab5-s3-bootstrap-1 Started
exit 0
LB ready: 200
--- after: api containers (name, id, StartedAt)
/mtusi-lab5-api-19 97b8c4574c46 2026-11-01T10:34:26.712304672Z
/mtusi-lab5-api-20 5aecf775f84d 2026-11-01T10:34:26.633759088Z
--- repeat with the same key, the same session
idempotency-key: <key>
201 x-request-id: 22bc07391e784d0883fd07463c6ad179 x-instance-id: 97b8c4574c46
{
"id": "838a93d9-cffc-4fbe-94e8-413f9ab191fa",
"chat_id": "f71fb930-1195-42af-b70e-b80661bc22f6",
"sender_id": "1b623133-e1dc-4fca-a8a2-50caf09536ed",
"text": "replay after restart",
"created_at": "2026-11-01T10:34:21.613999Z",
"attachment_ids": []
}
--- other body with the same key
idempotency-key: <key>
409 x-request-id: 7b46b5bcc2a5446c8ca84ec664dcfd10 x-instance-id: 97b8c4574c46
{
"error": {
"code": "conflict",
"message": "Idempotency key was already used with another request",
"request_id": "7b46b5bcc2a5446c8ca84ec664dcfd10"
}
}
--- history
{"count":1,"ids":["838a93d9-cffc-4fbe-94e8-413f9ab191fa"]}
--- compare
Message of the repeat = Message of the first send: yes
```