docs: add upload-memory evidence and report

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 15:39:58 +03:00
co-authored by Claude Opus 5.5
parent ce1ae2ccfe
commit 79cc06b1e0
8 changed files with 620 additions and 157 deletions
+100 -73
View File
@@ -1,31 +1,32 @@
# `make failure_checks`: проверки отказов с уборщиком и согласованностью БД и S3
# `make failure_checks`: проверки отказов с уборщиком, согласованностью БД и S3 и местами загрузки
- Дата: 2026-10-21, 19:09:23–19:13:29 UTC.
- Commit: `5889ca2` (правки change `upload-consistency` по повторному
verify: уборщик в два шага — пометка строки, затем объект и строка
одной транзакцией под блокировкой); рабочее дерево чистое (`git status`
пуст), образ собран из него.
- Дата: 2026-10-22, 12:25:26–12:30:08 UTC.
- Commit: `ce1ae2c` (код — `97a4be4`, change `upload-memory`: места
загрузки процесса, срок тела, одна копия тела при PUT, буферы LB). В
рабочем дереве — только незакоммиченные документы (`evidence/`,
`tasks.md`, `PLAN.md`), `src/` и `student-tests/` совпадают с commit;
образ собран из дерева.
- Стенд отказов: проект `mtusi-lab4-failures` — свои PostgreSQL, Valkey
и S3 (с bootstrap, пользователи `api` и `cleaner`), порты хранилищ не
публикуются; уборщик `cleaner` с grace 20 с и интервалом 1 с
(`failures.compose.yml`, `restart: "no"`); два API на `127.0.0.1`:
обычный — с `MAX_UPLOAD_BYTES=1` и `MAX_IMAGE_PIXELS=1` в окружении, и
«тесный» (сроки сессии и ключа 2 с, пул 1). Рабочий стенд `mtusi-lab4`
в это время запущен на том же commit (`make rolling_update`, затем
`docker compose up -d --no-deps --force-recreate cleaner`). Docker
Desktop 29.9.1, Apple M3 Pro.
(`failures.compose.yml`, `restart: "no"`); три API на `127.0.0.1`:
обычный — с `MAX_UPLOAD_BYTES=1` и `MAX_IMAGE_PIXELS=1` в окружении,
«тесный» (сроки сессии и ключа 2 с, пул 1) и с change `upload-memory`
«узкий по загрузкам» (`UPLOADS_ENV`: 1 место, 1 в очереди, ожидание
1 с, срок тела 2 с). Рабочий стенд `mtusi-lab4` в это время запущен на
том же коде (`make rolling_update` в 12:24, LB — на `127.0.0.1:8090`:
8080 хоста занят контейнером другого проекта). Docker Desktop 29.9.1,
Apple M3 Pro.
- Прежние снимки этого файла: commit `5b42bd2` — 29 из 29 за 190 с;
`87c48b9` — 32 из 32 за 224 с (три теста по замечаниям verify W1–W3,
design change `upload-consistency`, «Уточнения apply», п. 16–18).
Сейчас — 32 из 32 за 228 с; тесты не менялись, меняется только порядок
шагов уборщика (п. 21).
`87c48b9` — 32 из 32 за 224 с; `5889ca2` — 32 из 32 за 228 с. Сейчас —
37 из 37 за 255 с: пять новых тестов мест загрузки и срока тела (раздел
«Места загрузки и срок тела» ниже).
## Итог: код 0, 32 из 32
## Итог: код 0, 37 из 37
Вывод сборки образа (BuildKit), строки `Container …` compose, записи
alembic о прежних пяти ревизиях и журналы контейнеров стенда опущены;
путь к рабочему каталогу в строках `platform` и `rootdir` pytest заменён
на `…`.
alembic, вывод bootstrap S3 и журналы контейнеров стенда опущены; путь к
рабочему каталогу в строках `platform` и `rootdir` pytest заменён на `…`.
```
$ make failure_checks
@@ -34,60 +35,59 @@ python3 student-tests/run_failures.py
[failure_checks] build image
[failure_checks] start postgres, valkey and s3
[failure_checks] migrations
{"event": "Running upgrade ef25d50b01a8 -> 739b8f04d5fb, added pending attachments index", "instance_id": "1a6d5ceec824", "level": "info", "logger": "alembic.runtime.migration", "timestamp": "2026-10-21T19:09:30.354306Z"}
[failure_checks] s3 bootstrap
s3-bootstrap-1 | s3-bootstrap: bucket messenger created
s3-bootstrap-1 | s3-bootstrap: user api created
s3-bootstrap-1 | s3-bootstrap: user cleaner created
s3-bootstrap-1 | s3-bootstrap: checks passed (api key put/get; cleaner key get/delete; api key list and bucket create, cleaner key put and list, anonymous get and list denied)
s3-bootstrap-1 exited with code 0
[failure_checks] start cleaner: grace 20 s, interval 1 s
[failure_checks] start api containers
[failure_checks] ready: api=http://127.0.0.1:61810 tight=http://127.0.0.1:61814
[failure_checks] ready: api=http://127.0.0.1:65321 tight=http://127.0.0.1:65326 uploads=http://127.0.0.1:65330
[failure_checks] pytest -m fault
platform darwin -- Python 3.12.12, pytest-9.1.1, pluggy-1.6.0 -- …
collecting ... collected 229 items / 197 deselected / 32 selected
student-tests/test_failures.py::test_expired_token PASSED [ 3%]
student-tests/test_failures.py::test_use_does_not_extend_session PASSED [ 6%]
student-tests/test_failures.py::test_token_while_database_stopped PASSED [ 9%]
student-tests/test_failures.py::test_members_failure_rolls_back_chat PASSED [ 12%]
student-tests/test_failures.py::test_database_stopped_and_back PASSED [ 15%]
student-tests/test_failures.py::test_pool_exhausted PASSED [ 18%]
student-tests/test_failures.py::test_connection_limit_reached PASSED [ 21%]
student-tests/test_failures.py::test_pool_keeps_connections PASSED [ 25%]
student-tests/test_failures.py::test_readiness_without_database PASSED [ 28%]
student-tests/test_failures.py::test_readiness_without_cache PASSED [ 31%]
student-tests/test_failures.py::test_readiness_without_object_storage[stop] PASSED [ 34%]
student-tests/test_failures.py::test_readiness_without_object_storage[pause] PASSED [ 37%]
student-tests/test_failures.py::test_flush_cache PASSED [ 40%]
student-tests/test_failures.py::test_valkey_stopped PASSED [ 43%]
student-tests/test_failures.py::test_valkey_paused PASSED [ 46%]
student-tests/test_failures.py::test_valkey_back PASSED [ 50%]
student-tests/test_failures.py::test_message_failure_keeps_key_free PASSED [ 53%]
student-tests/test_failures.py::test_database_outage_keeps_key_free PASSED [ 56%]
student-tests/test_failures.py::test_key_free_after_ttl PASSED [ 59%]
student-tests/test_failures.py::test_upload_with_object_storage_stopped PASSED [ 62%]
student-tests/test_failures.py::test_rejected_uploads_leave_nothing PASSED [ 65%]
student-tests/test_failures.py::test_metadata_insert_failure PASSED [ 68%]
student-tests/test_failures.py::test_interrupted_body PASSED [ 71%]
student-tests/test_failures.py::test_ready_failure_compensated PASSED [ 75%]
student-tests/test_failures.py::test_killed_between_put_and_ready PASSED [ 78%]
student-tests/test_failures.py::test_ready_commit_outcome_unknown PASSED [ 81%]
student-tests/test_failures.py::test_upload_outlives_grace PASSED [ 84%]
student-tests/test_failures.py::test_cleaner_failure_after_object_delete PASSED [ 87%]
student-tests/test_failures.py::test_cleaner_survives_outages PASSED [ 90%]
student-tests/test_failures.py::test_object_storage_stopped PASSED [ 93%]
student-tests/test_failures.py::test_environment_does_not_change_limits PASSED [ 96%]
student-tests/test_failures.py::test_object_storage_paused PASSED [100%]
collecting ... collected 235 items / 198 deselected / 37 selected
student-tests/test_failures.py::test_expired_token PASSED [ 2%]
student-tests/test_failures.py::test_use_does_not_extend_session PASSED [ 5%]
student-tests/test_failures.py::test_token_while_database_stopped PASSED [ 8%]
student-tests/test_failures.py::test_members_failure_rolls_back_chat PASSED [ 10%]
student-tests/test_failures.py::test_database_stopped_and_back PASSED [ 13%]
student-tests/test_failures.py::test_pool_exhausted PASSED [ 16%]
student-tests/test_failures.py::test_connection_limit_reached PASSED [ 18%]
student-tests/test_failures.py::test_pool_keeps_connections PASSED [ 21%]
student-tests/test_failures.py::test_readiness_without_database PASSED [ 24%]
student-tests/test_failures.py::test_readiness_without_cache PASSED [ 27%]
student-tests/test_failures.py::test_readiness_without_object_storage[stop] PASSED [ 29%]
student-tests/test_failures.py::test_readiness_without_object_storage[pause] PASSED [ 32%]
student-tests/test_failures.py::test_flush_cache PASSED [ 35%]
student-tests/test_failures.py::test_valkey_stopped PASSED [ 37%]
student-tests/test_failures.py::test_valkey_paused PASSED [ 40%]
student-tests/test_failures.py::test_valkey_back PASSED [ 43%]
student-tests/test_failures.py::test_message_failure_keeps_key_free PASSED [ 45%]
student-tests/test_failures.py::test_database_outage_keeps_key_free PASSED [ 48%]
student-tests/test_failures.py::test_key_free_after_ttl PASSED [ 51%]
student-tests/test_failures.py::test_upload_with_object_storage_stopped PASSED [ 54%]
student-tests/test_failures.py::test_rejected_uploads_leave_nothing PASSED [ 56%]
student-tests/test_failures.py::test_metadata_insert_failure PASSED [ 59%]
student-tests/test_failures.py::test_interrupted_body PASSED [ 62%]
student-tests/test_failures.py::test_ready_failure_compensated PASSED [ 64%]
student-tests/test_failures.py::test_killed_between_put_and_ready PASSED [ 67%]
student-tests/test_failures.py::test_ready_commit_outcome_unknown PASSED [ 70%]
student-tests/test_failures.py::test_upload_outlives_grace PASSED [ 72%]
student-tests/test_failures.py::test_cleaner_failure_after_object_delete PASSED [ 75%]
student-tests/test_failures.py::test_cleaner_survives_outages PASSED [ 78%]
student-tests/test_failures.py::test_object_storage_stopped PASSED [ 81%]
student-tests/test_failures.py::test_environment_does_not_change_limits PASSED [ 83%]
student-tests/test_failures.py::test_object_storage_paused PASSED [ 86%]
student-tests/test_failures.py::test_upload_slots_busy PASSED [ 89%]
student-tests/test_failures.py::test_rejections_before_queue PASSED [ 91%]
student-tests/test_failures.py::test_upload_waits_for_slot PASSED [ 94%]
student-tests/test_failures.py::test_slot_released_after_failures PASSED [ 97%]
student-tests/test_failures.py::test_slow_body PASSED [100%]
================ 32 passed, 197 deselected in 228.04s (0:03:48) ================
[failure_checks] postgres log: 436 lines, crash markers 0; "too many clients" 31, "administrator command" 138
================ 37 passed, 198 deselected in 255.11s (0:04:15) ================
[failure_checks] postgres log: 447 lines, crash markers 0; "too many clients" 36, "administrator command" 144
[failure_checks] cleanup
[failure_checks] results: {'fault': 0, 'postgres': 0}
exit=0
```
Вся команда — 246 с (19:09:23–19:13:29). «too many clients» и
Вся команда — ~4 мин 40 с (12:25:26–12:30:08). «too many clients» и
«administrator command» — следы проверок «Предел соединений PostgreSQL
исчерпан» (`fill-connections`) и остановок PostgreSQL, признаков
аварийного перезапуска нет.
@@ -95,21 +95,48 @@ exit=0
## Уборка и рабочий стенд
```
$ docker inspect -f '{{.Name}} {{.State.StartedAt}}' $(docker compose ps -q) # до и после — одинаково
/mtusi-lab4-api-15 2026-10-21T19:08:44.74597043Z
/mtusi-lab4-api-16 2026-10-21T19:08:48.805083335Z
/mtusi-lab4-cleaner-1 2026-10-21T19:08:58.331389589Z
/mtusi-lab4-haproxy-1 2026-10-21T03:30:26.991596804Z
/mtusi-lab4-postgres-1 2026-10-21T03:30:05.896306378Z
/mtusi-lab4-s3-1 2026-10-21T03:30:20.918287843Z
/mtusi-lab4-valkey-1 2026-10-21T03:30:05.925240128Z
$ docker inspect -f '{{.Name}} {{.State.StartedAt}}' $(docker compose ps -q) # после прогона
/mtusi-lab4-api-19 2026-10-22T12:24:16.659281295Z
/mtusi-lab4-api-20 2026-10-22T12:24:34.073897804Z
/mtusi-lab4-cleaner-1 2026-10-22T06:29:15.606982427Z
/mtusi-lab4-haproxy-1 2026-10-22T06:30:24.692639417Z
/mtusi-lab4-postgres-1 2026-10-22T06:29:08.988292382Z
/mtusi-lab4-s3-1 2026-10-22T06:29:08.828629465Z
/mtusi-lab4-valkey-1 2026-10-22T06:29:08.904727882Z
left: containers 0, volumes 0
```
- `StartedAt` всех контейнеров `mtusi-lab4`, в том числе его уборщика,
до и после совпали: рабочий стенд не тронут.
- Все контейнеры `mtusi-lab4` стартовали раньше прогона (последние —
реплики после `make rolling_update` в 12:24:16 и 12:24:34; прогон — с
12:25:26): рабочий стенд не тронут.
- У проекта `mtusi-lab4-failures` не осталось ни контейнеров, ни volumes.
## Места загрузки и срок тела (change `upload-memory`)
«Узкий по загрузкам» API: 1 место, 1 в очереди, ожидание 1 с, срок тела
2 с; тесты сверяют это окружение (`FAULT_UPLOADS_ENV`). Место держит
загрузка A, тело которой стоит на `threading.Event` теста.
- «Все места заняты», «Очередь ожидания полна», `api-conventions` «Лимит
одновременных загрузок» (`test_upload_slots_busy`): A держит место, B
ждёт, C получает 429 `rate_limited` быстрее 0,5 с, B — 429 не раньше
1 с; у обоих `Retry-After` — положительное целое ≥ 1, формат ошибки и
`X-Instance-Id`; A после отпускания — 201; новые строка и объект —
только у A.
- «Отказ раньше очереди» (`test_rejections_before_queue`): при полной
очереди посторонний — 404, 30 MiB с `Content-Length` 31 457 280 — 413,
`Content-Type: text/plain` — 415, каждый быстрее срока ожидания и
раньше 429 ожидавшей B.
- «Ожидание места» и `storage-consistency` «Ожидание места не входит в
возраст загрузки» (`test_upload_waits_for_slot`): B ждёт и получает
201, `B.created_at` позже `A.updated_at`, обе скачиваются побайтно.
- «Место освобождается» (`test_slot_released_after_failures`): после 413
по счётчику, 415 по содержимому, 400 по сроку тела, обрыва тела и 503
при остановленном S3 следующая загрузка — 201 быстрее срока ожидания.
- «Медленный клиент», «Медленная передача в срок» (`test_slow_body`):
тело частями дольше 2 с — 400 «Upload body was not received in time»,
ни строки, ни объекта; мелкими частями в срок — 201 с тем же SHA-256.
## Что проверяют проверки вложений и уборщика
Строки и объекты тесты сравнивают множествами `id` от hook