Files
mtusi2026lab2/evidence/storage/restart.md
T
ricoromaandClaude Opus 5.5 484914c38a docs: add evidence for postgres-storage verify fixes
- statement timeout: 503 and no SQL parameters in logs, before and after
- failed migration keeps the API from starting
- fresh clone: console from zero, then docker and make down
- restart evidence with docker compose ps

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

66 lines
3.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.
# Рестарт стенда hook-ом: данные и порядок участников на месте
| | |
|---|---|
| Спеки | `data-storage` «Прежний пользователь после рестарта», `container-run` «Рестарт hook-ом» |
| Change | `postgres-storage`, задачи 6.2 и 9.4 |
| Дата | 2026-10-01 13:42 UTC |
| Commit | `125145d` |
| Стенд | `make run_docker` (compose: postgres, migrate, api), API на `127.0.0.1:8080` |
| Хост | Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7 GiB RAM; лимиты контейнерам не задавались |
| Клиент | разовый stdlib-скрипт: HTTP по контракту, `docker compose ps` и `docker inspect` до и после `scripts/restart.sh`; id сокращены, тексты синтетические |
| Идентификация | `X-User-Id` (лаба 1, до change `session-auth`) |
## Данные до рестарта
| Запрос | Статус | Результат |
|---|---|---|
| `POST /users` (alice) | 201 | id `29d50938…` |
| `POST /users` (bob) | 201 | id `48df8491…` |
| `POST /chats` (alice, участники `[bob, alice]`) | 201 | id `1bcb2051…` |
| `POST …/messages` (alice) | 201 | id `324c2d80…` |
| `POST …/messages` (bob) | 201 | id `c50b225f…` |
| `POST …/messages` (alice) | 201 | id `a62f3ed3…` |
## Рестарт: `scripts/restart.sh`
Код выхода 0 за 3,5 с; `/health/ready` — 200 через 1,0 с после hook.
| Контейнер | `StartedAt` до | `StartedAt` после | Перезапущен |
|---|---|---|---|
| `mtusi-lab2-api-1` | 2026-10-01T13:42:09.023209757Z | 2026-10-01T13:42:23.779999417Z | да |
| `mtusi-lab2-postgres-1` | 2026-10-01T13:25:13.52261101Z | 2026-10-01T13:42:20.922689888Z | да |
```text
$ docker compose ps -a # до hook
mtusi-lab2-api-1 Up 11 seconds (healthy)
mtusi-lab2-migrate-1 Exited (0) 11 seconds ago
mtusi-lab2-postgres-1 Up 17 minutes (healthy)
$ docker compose ps -a # сразу после hook
mtusi-lab2-api-1 Up Less than a second (health: starting)
mtusi-lab2-migrate-1 Exited (0) Less than a second ago
mtusi-lab2-postgres-1 Up 3 seconds (healthy)
$ docker compose ps -a # после готовности API
mtusi-lab2-api-1 Up 1 second (healthy)
mtusi-lab2-migrate-1 Exited (0) 1 second ago
mtusi-lab2-postgres-1 Up 4 seconds (healthy)
```
`migrate` тоже прошёл заново: его запускает `start api` как
зависимость. Повторный прогон миграций — no-op
(`evidence/migrations/from-zero-and-rerun.md`).
## После рестарта
| Запрос | Статус | Результат | Проверка |
|---|---|---|---|
| `GET /users/me` (alice) | 200 | id `29d50938…` | тот же id: да |
| `GET /chats/{id}` (bob) | 200 | id `1bcb2051…` | порядок `member_ids` тот же (`[bob, alice]`): да |
| `GET …/messages` (bob) | 200 | items: 3 | те же сообщения в том же порядке: да |
## Вывод
Оба контейнера перезапущены (новый `StartedAt`, `Up` с нуля в `docker
compose ps`), volume `postgres_data` не трогался. Прежний `X-User-Id`
видит свои данные, порядок `member_ids` и истории сохранился.