Files
mtusi2026lab4/evidence/s3/restart.md
T
ricoromaandClaude Opus 5.5 1471f07a0e docs: re-capture s3-storage evidence after verify fixes
- evidence/s3 and evidence/tests re-captured from f57635a: first write
  after healthy, deleted bucket, netstat-based port check, readiness
  with s3 paused, prefix cleanup check
- PLAN: HEAD on a deleted bucket is an accepted limitation
- KNOWN_ISSUES: bootstrap after a manual bucket delete

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

161 lines
8.7 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.
# Рестарт стенда с S3, первая запись после healthy и SIGKILL сервера S3
- Дата: 2026-10-20, 18:25–18:32 UTC.
- Commit: `f57635a` (рабочее дерево — только `PLAN.md` вне кода).
- Стенд: `make run_docker` с этого commit, проект `mtusi-lab4`. Docker
Desktop 29.8.2, compose 5.5.1, Apple M3 Pro.
- Спек `container-run`: «Рестарт hook-ом»; `object-storage`: «Рестарт
стенда», «Принудительное завершение», «Первая запись после healthy»,
«Остановка сервера». Design change `s3-storage`, решения 1, 9 и
«Уточнения apply», п. 8.
- Публичный `make test-persistence` до change `attachments` красный: он
загружает вложение до вызова hook (design, Context). Поэтому hook
проверен напрямую.
- Объекты пишет и читает клиент приложения `src/infra/s3` в консоли
(`persist_probe.py`, `first_write.py`, scratchpad) ключом API. Размеры
объектов `persist_probe.py` — 200 000 + i × 50 000 байт.
## 1. `scripts/restart.sh`
```
$ persist_probe.py write 3
written and confirmed: 3 objects
--- before
mtusi-lab4-api-1 15f355a7ce5e 2026-10-20T18:24:50.487701511Z running
mtusi-lab4-api-2 d6afabc6d77a 2026-10-20T18:24:50.566243511Z running
mtusi-lab4-haproxy-1 1d3b522e85fa 2026-10-20T17:39:52.595685345Z running
mtusi-lab4-migrate-1 2350a38cc289 2026-10-20T18:24:48.331502718Z exited
mtusi-lab4-postgres-1 29c7b37863c1 2026-10-20T17:39:29.787738376Z running
mtusi-lab4-s3-1 805bf7f382ac 2026-10-20T18:09:29.991872709Z running
mtusi-lab4-s3-bootstrap-1 7bfe3a481799 2026-10-20T18:24:48.250103551Z exited
mtusi-lab4-valkey-1 bd4329833fcc 2026-10-20T17:39:29.760681585Z running
$ time scripts/restart.sh
exit=0, 24 s
--- after
mtusi-lab4-api-1 15f355a7ce5e 2026-10-20T18:25:44.219750924Z running
mtusi-lab4-api-2 d6afabc6d77a 2026-10-20T18:25:44.306628049Z running
mtusi-lab4-haproxy-1 1d3b522e85fa 2026-10-20T18:25:44.411630841Z running
mtusi-lab4-migrate-1 2350a38cc289 2026-10-20T18:25:41.455557798Z exited
mtusi-lab4-postgres-1 29c7b37863c1 2026-10-20T18:25:21.474698136Z running
mtusi-lab4-s3-1 805bf7f382ac 2026-10-20T18:25:36.474543254Z running
mtusi-lab4-s3-bootstrap-1 7bfe3a481799 2026-10-20T18:25:41.611018257Z exited
mtusi-lab4-valkey-1 bd4329833fcc 2026-10-20T18:25:21.447281886Z running
$ docker compose logs --no-log-prefix s3-bootstrap (запуск после рестарта)
s3-bootstrap: bucket messenger exists
s3-bootstrap: user api exists
s3-bootstrap: checks passed (api key put/get/delete; api key list and bucket create, anonymous get and list denied)
$ persist_probe.py verify
read back with the same SHA-256: 3/3; deleted
hook output lines with secret|password|key=: 0
```
- Перезапущены LB, обе реплики, PostgreSQL, Valkey и S3: ID контейнеров
прежние, `StartedAt` у всех новый. `migrate` и `s3-bootstrap` снова
выполнены как зависимости `start api`.
- Hook занял 24 с при сроке 90 с, из них ~15 с — плавная остановка
SeaweedFS (`stop_grace_period: 20s`).
- Bootstrap после рестарта ничего не изменил («exists»), объекты
прочитаны с тем же SHA-256.
- Сразу после возврата hook LB ответил 503 «No API replica is available»:
реплики ещё стартовали. Готовность hook не ждёт, её ждёт сам тест
(`docker.md`, `scripts/restart.sh`). Через полминуты `GET /health/ready`
через LB — `{"status":"ok"}`, все сервисы `healthy`.
- В выводе hook нет ни `secret`, ни `password`, ни `key=`.
## 2. Плавная остановка S3
```
docker compose stop s3: 15.3 s
ExitCode 0, OOMKilled false
up --wait s3: healthy
```
Сервер завершился сам за 15,3 с при `stop_grace_period: 20s`, код 0:
SIGKILL по сроку не понадобился.
## 3. SIGKILL сразу после подтверждённых записей
```
$ persist_probe.py write 20 && docker kill -s KILL mtusi-lab4-s3-1
written and confirmed: 20 objects
after kill: status exited, exit 137
$ docker compose up -d --wait s3
healthy in 5 s
$ persist_probe.py verify
read back with the same SHA-256: 20/20; deleted
```
Все 20 подтверждённых объектов пережили SIGKILL процесса. Отказ диска или
ВМ этим не покрыт: одна нода без реплик (`REPORT.md`, «Ограничения»).
## 4. Первая запись после `healthy`
Находка verify W1: healthcheck проверял master, filer и шлюз, но не
регистрацию тома у master. Тогда `healthy` иногда наступал раньше, чем
том мог принять запись, и первая запись ждала его до 4,8 с при сроке
вызова клиента 5 с. С `f57635a` healthcheck ещё и ждёт непустой
`DataNodes` в `/dir/status` master.
### Шкала старта
`ev8_timeline.sh` (scratchpad): `docker compose stop s3` + `start`, затем
раз в ~0,6 с — прежняя проверка (master, filer, шлюз), регистрация тома и
статус healthcheck Docker.
```
0.0 s: master+filer+gateway=no data_node=no docker=starting
0.6 s: master+filer+gateway=no data_node=no docker=starting
1.1 s: master+filer+gateway=no data_node=no docker=starting
1.7 s: master+filer+gateway=no data_node=yes docker=starting
2.3 s: master+filer+gateway=no data_node=yes docker=starting
2.9 s: master+filer+gateway=no data_node=yes docker=starting
3.5 s: master+filer+gateway=yes data_node=yes docker=starting
4.2 s: master+filer+gateway=yes data_node=yes docker=healthy
summary: old check passes at 3.5s, data node registered at 1.7s, docker healthy at 4.2s
summary: old check passes at 3.4s, data node registered at 6.9s, docker healthy at 7.5s
summary: old check passes at 3.4s, data node registered at 1.7s, docker healthy at 4.1s
```
Во втором из трёх стартов том зарегистрировался через 6,9 с, на 3,5 с
позже прежней проверки: прежний `healthy` пришёлся бы на это окно.
Теперь `healthy` ждёт регистрацию.
### Время первой записи
`first_write.py` (scratchpad): запись, затем рестарт `s3` (`docker compose
restart s3`, 12 раз) или `docker kill -s KILL` (6 раз) и `docker compose
up -d --wait s3`, сразу первая и вторая запись. Срок вызова на время
пробы — 30 с (`S3__TIMEOUT_SECONDS=30`), чтобы видеть ожидание, а не
таймаут.
```
restart #1: healthy after 20.2s, first put 24 ms, second 6 ms
restart #2: healthy after 18.6s, first put 17 ms, second 4 ms
restart #3: healthy after 18.5s, first put 12 ms, second 11 ms
restart #4: healthy after 23.0s, first put 21 ms, second 5 ms
restart #5: healthy after 19.2s, first put 23 ms, second 6 ms
restart #6: healthy after 23.2s, first put 15 ms, second 3 ms
restart #7: healthy after 20.1s, first put 15 ms, second 3 ms
restart #8: healthy after 19.6s, first put 13 ms, second 4 ms
restart #9: healthy after 23.2s, first put 27 ms, second 6 ms
restart #10: healthy after 19.7s, first put 13 ms, second 3 ms
restart #11: healthy after 23.3s, first put 20 ms, second 3 ms
restart #12: healthy after 20.1s, first put 23 ms, second 6 ms
kill #1: healthy after 7.9s, first put 23 ms, second 6 ms
kill #2: healthy after 3.9s, first put 21 ms, second 7 ms
kill #3: healthy after 3.9s, first put 11 ms, second 5 ms
kill #4: healthy after 3.9s, first put 16 ms, second 4 ms
kill #5: healthy after 3.9s, first put 11 ms, second 4 ms
kill #6: healthy after 3.9s, first put 17 ms, second 7 ms
```
- Первая запись после `healthy` — 11–27 мс во всех 18 случаях, при сроке
вызова 5 с.
- `healthy after` при рестарте включает плавную остановку (~15 с).
- До правки тот же скрипт на прежнем healthcheck (2026-10-20, ~18:00
UTC, код `7d340c0`): 8 рестартов, первая запись в двух — 4771 и 2523 мс,
в остальных 9–16 мс. Verify: в 3 из 12 — 4775–4784 мс.
Секретов в выводах нет: `grep -F` значений секретов стенда по выводам
hook, `persist_probe.py` и `first_write.py` — 0 совпадений.