docs: add upload-memory evidence and report
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,38 +1,36 @@
|
||||
# `make student_test` через балансировщик
|
||||
|
||||
- Дата: 2026-10-21, 18:35:35–18:36:25 UTC (пересъёмка после правок
|
||||
change `upload-consistency` по verify); счёт по модулям — повторный
|
||||
прогон 18:36–18:37 с тем же итогом (197 passed, 32 deselected).
|
||||
- Commit: `87c48b9`; вне commit — только файлы `evidence/` и `REPORT.md`
|
||||
второго этапа правок (код стенда собран из чистого дерева этого
|
||||
commit).
|
||||
- Стенд: рабочий `mtusi-lab4` после `make rolling_update` с этого commit
|
||||
— `BASE_URL=http://localhost:8080` (HAProxy), `EXPECT_REPLICAS=2`
|
||||
(`API_REPLICAS`): реплики `17d8dd756626` и `b3c055808ddf`, PostgreSQL,
|
||||
Valkey, S3, уборщик `cleaner` на том же образе. Тесты реплик
|
||||
выполняются, проверки отказов (`fault`) — нет (`-m 'not fault'`, их
|
||||
гоняет `make failure_checks`, `failure-checks.md`).
|
||||
- Что изменилось с прежнего снимка (commit `5b42bd2`): три новых
|
||||
сценария по замечаниям verify — «Исход фиксации неизвестен»
|
||||
(`attachments`), «Загрузка дольше grace» и «Сбой уборки после удаления
|
||||
объекта» (`storage-consistency`, теперь 8 сценариев). Итог — 215
|
||||
сценариев в 13 спеках, из них 36 покрыты проверками отказов (было 212 и
|
||||
33); проверок отказов в наборе 32 (было 29), поэтому `deselected` —
|
||||
32. Число выполняемых тестов то же — 197.
|
||||
- Файлы исключений сверки покрытия сняты на стенде лабы 4 (commit
|
||||
`8dc925e`: `evidence/cache/hits.md`,
|
||||
`evidence/auth/passwords-and-tokens.md`,
|
||||
`evidence/idempotency/replay-after-restart.md`,
|
||||
`evidence/replicas/test-persistence.md`,
|
||||
`evidence/attachments/failover.md`, `evidence/attachments/storage.md`):
|
||||
- Дата: 2026-10-22, 12:34:28–12:35:09 UTC (пересъёмка после change
|
||||
`upload-memory`).
|
||||
- Commit: `ce1ae2c` (код — `97a4be4`); вне commit — только документы
|
||||
(`evidence/`, `tasks.md`, `PLAN.md`), код стенда собран из дерева с
|
||||
тем же `src/`.
|
||||
- Стенд: рабочий `mtusi-lab4` после `make rolling_update` (12:24) —
|
||||
`BASE_URL=http://localhost:8090`: **LB на 8090, а не на 8080 из
|
||||
`.env`**, порт 8080 хоста занят контейнером другого проекта
|
||||
(`domains-api-1`); `EXPECT_REPLICAS=2` (`API_REPLICAS`): реплики
|
||||
`3b96c600b25a` и `f6915f9b80dc`, PostgreSQL, Valkey, S3, уборщик
|
||||
`cleaner`. Тесты реплик выполняются, проверки отказов (`fault`) — нет
|
||||
(`-m 'not fault'`, их гоняет `make failure_checks`, `failure-checks.md`).
|
||||
- Что изменилось с прежнего снимка (commit `87c48b9`): change
|
||||
`upload-memory` — новый тест `test_concurrent_uploads` («Загрузки в
|
||||
пределах лимита», 10 одновременных загрузок PNG ~1 MiB), пять новых
|
||||
проверок отказов мест загрузки и срока тела (`deselected` 37 вместо 32)
|
||||
и два исключения сверки — «Одна копия тела при записи в S3» и «Память
|
||||
не растёт с числом загрузок» со ссылкой на метку
|
||||
`evidence/uploads/baseline/summary.md` (`make bench_uploads`, commit
|
||||
`ce1ae2c`). Итог сверки — 227 сценариев в 13 спеках, 210 с тестами (45
|
||||
— проверками отказов), 17 исключений.
|
||||
- Файлы исключений сверки покрытия есть в репозитории (прежние шесть —
|
||||
commit `8dc925e`, метка `baseline` — `ce1ae2c`):
|
||||
`test_exclusion_evidence_exists` зелёный.
|
||||
|
||||
## Итог
|
||||
|
||||
```
|
||||
$ make student_test
|
||||
coverage: 215 scenarios in 13 specs, 200 tested (36 by make failure_checks), 15 excluded
|
||||
===================== 197 passed, 32 deselected in 48.84s ======================
|
||||
$ make student_test BASE_URL=http://localhost:8090
|
||||
coverage: 227 scenarios in 13 specs, 210 tested (45 by make failure_checks), 17 excluded
|
||||
===================== 198 passed, 37 deselected in 40.23s ======================
|
||||
exit=0
|
||||
```
|
||||
|
||||
@@ -40,7 +38,7 @@ exit=0
|
||||
|
||||
```
|
||||
21 student-tests/test_api_conventions.py PASSED
|
||||
33 student-tests/test_attachments.py PASSED
|
||||
34 student-tests/test_attachments.py PASSED
|
||||
4 student-tests/test_chat_cache.py PASSED
|
||||
13 student-tests/test_chats.py PASSED
|
||||
12 student-tests/test_contract.py PASSED
|
||||
@@ -61,31 +59,37 @@ exit=0
|
||||
## Строки тестов реплик и гонок (`-rsP`)
|
||||
|
||||
```
|
||||
uploaded via 17d8dd756626, downloaded via ['17d8dd756626', 'b3c055808ddf']
|
||||
sent via 17d8dd756626, replayed via ['b3c055808ddf']
|
||||
409 via ['17d8dd756626', 'b3c055808ddf']
|
||||
one session, 20 requests: {'b3c055808ddf': 10, '17d8dd756626': 10}
|
||||
written via 17d8dd756626, read via {'b3c055808ddf': 3, '17d8dd756626': 3}
|
||||
two series of 18 requests: {'f6915f9b80dc': 18, '3b96c600b25a': 18}
|
||||
uploaded via f6915f9b80dc, downloaded via ['3b96c600b25a', 'f6915f9b80dc']
|
||||
sent via f6915f9b80dc, replayed via ['3b96c600b25a']
|
||||
409 via ['3b96c600b25a', 'f6915f9b80dc']
|
||||
one session, 20 requests: {'3b96c600b25a': 10, 'f6915f9b80dc': 10}
|
||||
written via f6915f9b80dc, read via {'3b96c600b25a': 3, 'f6915f9b80dc': 3}
|
||||
race: 10 clients x 10 messages, statuses {201: 100}, max in flight 10; history: 100 messages, 100 unique ids, 4 pages by 30
|
||||
username race: 10 clients, statuses {409: 9, 201: 1}, max in flight 10
|
||||
key race: 10 clients, statuses {201: 10}, max in flight 10; history: 1 messages
|
||||
key race: 10 clients, statuses {201: 10}, max in flight 10; history: 1 messages
|
||||
key race through replicas: {'b3c055808ddf': 5, '17d8dd756626': 5}
|
||||
key race through replicas: {'3b96c600b25a': 5, 'f6915f9b80dc': 5}
|
||||
```
|
||||
|
||||
- Вложения лабы 4: 33 теста спека `attachments` (`test_attachments.py`)
|
||||
- Change `upload-memory`: `test_concurrent_uploads` — 10 участников одного
|
||||
чата загружают по PNG ~1 MiB через LB одновременно (за
|
||||
`threading.Barrier`, каждый своим соединением): все 201 с разными `id`,
|
||||
загрузки пересекались по времени, каждое вложение скачивается
|
||||
побайтно. 4 места и очередь 16 на реплику при параметрах по умолчанию
|
||||
их вмещают.
|
||||
- Вложения лабы 4: 34 теста спека `attachments` (`test_attachments.py`)
|
||||
и пять сценариев рубрики «4» лабы 4 в `test_rubric.py` (слишком
|
||||
большой файл, повреждённое изображение, подмена MIME, чужое
|
||||
`attachment_id`, вложение другого чата): каждая ошибка клиента — 4xx
|
||||
в формате контракта, не 500. «Скачивание через другую реплику»:
|
||||
загрузку принял `17d8dd756626`, оригинал отдал и `b3c055808ddf`.
|
||||
- Новый после verify тест `test_filename_not_utf8` (сценарий «Имя не в
|
||||
UTF-8»): `filename=a%FFb.png`, `a%C3.png`, `a%ED%A0%80b.png` — 400,
|
||||
`%C3%A9t%C3%A9.png` — 201 с `été.png`. На коде до правки (`8dc925e`)
|
||||
все три первых давали 201 (U+FFFD вместо байта).
|
||||
загрузку принял `f6915f9b80dc`, оригинал отдал и `3b96c600b25a`.
|
||||
- `test_filename_not_utf8` (сценарий «Имя не в UTF-8»):
|
||||
`filename=a%FFb.png`, `a%C3.png`, `a%ED%A0%80b.png` — 400,
|
||||
`%C3%A9t%C3%A9.png` — 201 с `été.png`.
|
||||
- Уровень 4 лаб 2–3: 100 сообщений от 10 клиентов — 100 уникальных в
|
||||
истории; гонка регистрации — один 201; гонка одного ключа через
|
||||
реплики — одно сообщение.
|
||||
- Сверка покрытия: все 215 сценариев 13 спеков — тест (200, из них 36
|
||||
проверками отказов, в том числе все 8 сценариев `storage-consistency`)
|
||||
или исключение с доказательством (15).
|
||||
- Сверка покрытия: все 227 сценариев 13 спеков — тест (210, из них 45
|
||||
проверками отказов, в том числе все 9 сценариев `storage-consistency`)
|
||||
или исключение с доказательством (17).
|
||||
|
||||
@@ -3,25 +3,30 @@
|
||||
- Спек `student-tests`: «Прогон на временной базе» (уборка префикса
|
||||
`test_<db>/`, «Хвост прошлого прогона», «Сохранить базу для разбора»).
|
||||
Design change `s3-storage`, решение 9 и «Уточнения apply», п. 11.
|
||||
- Раздел 0 — пересъёмка после правок change `upload-consistency` по
|
||||
verify (зелёная). Разделы 1–3 сняты на `f57635a` (change `s3-storage`):
|
||||
механизм уборки с тех пор не менялся (`student-tests/run_isolated.py`),
|
||||
а красное в них — ожидаемое до `attachments`, как сказано ниже.
|
||||
Прежние снимки раздела 0: commit `d56b892` (change `attachments`) — 191
|
||||
passed, 5 skipped, 23 deselected; `5b42bd2` — 192 passed, 5 skipped, 29
|
||||
deselected, сверка 212 / 33.
|
||||
- Раздел 0 — пересъёмка после change `upload-memory` (зелёная). Разделы
|
||||
1–3 сняты на `f57635a` (change `s3-storage`): механизм уборки с тех пор
|
||||
не менялся (`student-tests/run_isolated.py`), а красное в них —
|
||||
ожидаемое до `attachments`, как сказано ниже. Прежние снимки раздела
|
||||
0: commit `d56b892` (change `attachments`) — 191 passed, 5 skipped, 23
|
||||
deselected; `5b42bd2` — 192 passed, 5 skipped, 29 deselected, сверка
|
||||
212 / 33; `87c48b9` — 192 passed, 5 skipped, 32 deselected, сверка 215
|
||||
/ 36.
|
||||
|
||||
## 0. Пересъёмка: код 0 (change `upload-consistency`, правки по verify)
|
||||
## 0. Пересъёмка: код 0 (change `upload-memory`)
|
||||
|
||||
- Дата: 2026-10-21, 18:37:58–18:39:52 UTC.
|
||||
- Commit: `87c48b9`; рабочее дерево — только незакоммиченные файлы
|
||||
`evidence/` и `REPORT.md` второго этапа правок (образ собирается из
|
||||
дерева, код совпадает с commit).
|
||||
- Дата: 2026-10-22, 12:32:21–12:34:02 UTC.
|
||||
- Commit: `ce1ae2c` (код — `97a4be4`); рабочее дерево — только
|
||||
незакоммиченные документы (`evidence/`, `tasks.md`, `PLAN.md`), образ
|
||||
собирается из дерева, код совпадает с commit.
|
||||
- Стенд: рабочий `mtusi-lab4` (с уборщиком `cleaner`); временная база
|
||||
`test_messenger`, один контейнер API `mtusi-lab4-test-api` на
|
||||
`127.0.0.1:18088` без LB (`EXPECT_REPLICAS=1`), Valkey и S3 стенда
|
||||
общие. Перед прогоном цель запускает `start_s3` — bootstrap S3
|
||||
(пользователи `api` и `cleaner` уже есть).
|
||||
общие. Контейнер запущен `docker compose run` сервиса `api`, поэтому
|
||||
у него те же `sysctls` (`net.ipv4.tcp_rmem` до 512 KiB) и места
|
||||
загрузок по умолчанию (4 места, 16 в очереди): новый
|
||||
`test_concurrent_uploads` (10 одновременных загрузок по ~1 MiB) прошёл
|
||||
на одном процессе. Перед прогоном цель запускает `start_s3` —
|
||||
bootstrap S3 (пользователи `api` и `cleaner` уже есть).
|
||||
- Уборщик рабочего стенда объекты `test_messenger/` не видит: он
|
||||
работает со строками своей базы `messenger` и её префиксом; префикс
|
||||
временной базы убирает сам прогон.
|
||||
@@ -38,13 +43,13 @@ $ make test_isolated
|
||||
[test_isolated] make test
|
||||
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
|
||||
[test_isolated] make student_test
|
||||
coverage: 215 scenarios in 13 specs, 200 tested (36 by make failure_checks), 15 excluded
|
||||
SKIPPED [1] student-tests/test_attachments.py:648: one API process (EXPECT_REPLICAS=1): replica checks need the stand with the load balancer
|
||||
coverage: 227 scenarios in 13 specs, 210 tested (45 by make failure_checks), 17 excluded
|
||||
SKIPPED [1] student-tests/test_attachments.py:701: one API process (EXPECT_REPLICAS=1): replica checks need the stand with the load balancer
|
||||
SKIPPED [1] student-tests/test_idempotency.py:372: one API process (EXPECT_REPLICAS=1): replica checks need the stand with the load balancer
|
||||
SKIPPED [1] student-tests/test_load_balancing.py:18: one API process (EXPECT_REPLICAS=1): replica checks need the stand with the load balancer
|
||||
SKIPPED [1] student-tests/test_load_balancing.py:34: one API process (EXPECT_REPLICAS=1): replica checks need the stand with the load balancer
|
||||
SKIPPED [1] student-tests/test_race.py:169: one API process (EXPECT_REPLICAS=1): replica checks need the stand with the load balancer
|
||||
=========== 192 passed, 5 skipped, 32 deselected in 98.88s (0:01:38) ===========
|
||||
=========== 193 passed, 5 skipped, 37 deselected in 88.67s (0:01:28) ===========
|
||||
[test_isolated] cleanup
|
||||
[test_isolated] remove objects /buckets/messenger/test_messenger/
|
||||
[test_isolated] results: {'test': 0, 'student_test': 0}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
# Сроки LB на пути загрузки: `driver.py lb-upload-timeouts`
|
||||
|
||||
- Дата: 2026-10-22, 12:21–12:23 UTC.
|
||||
- Commit: `ce1ae2c` (конфигурация LB — `97a4be4`, change `upload-memory`).
|
||||
- Спек `load-balancing`: «Загрузки через балансировщик» (сценарии «Долгая
|
||||
обработка загрузки», «Прежний срок остальных путей», «Загрузка дольше
|
||||
срока LB») и «Ошибки балансировщика в формате контракта» («Клиент
|
||||
замолчал посреди тела»); design change `upload-memory`, решение 7.
|
||||
- Стенд: без рабочего стенда. Временная сеть `mtusi-lbto-<метка>`,
|
||||
HAProxy закреплённого образа с проверяемой конфигурацией и заглушка
|
||||
реплики под сетевым именем `api` на образе API (asyncio stdlib):
|
||||
`/health/ready` — 200, остальные пути — задержки по случаю. Пять
|
||||
случаев параллельно, каждый в своём соединении; тело — 10 MiB.
|
||||
Сети и контейнеры удалены после прогона (по метке
|
||||
`mtusi.lb-upload-timeouts` — 0 контейнеров, сетей `lbto` — 0).
|
||||
|
||||
## Текущая конфигурация (`infra/haproxy/haproxy.cfg`) — код 0
|
||||
|
||||
```
|
||||
$ python3 .claude/skills/run-mtusi-messenger/driver.py lb-upload-timeouts
|
||||
config infra/haproxy/haproxy.cfg
|
||||
haproxy haproxy:3.4.6-trixie@sha256:e273915691a8eab3f105bf3e39fd4c29a4ecf334e33421903b5589d25e14db26, stub image mtusi-messenger:lab4, LB 127.0.0.1:65097
|
||||
haproxy -c: exit 0
|
||||
case expected got time
|
||||
upload: replica silent 12 s before body 201 replica 11.5–17 s 201 replica 12.05 s
|
||||
upload: replica silent 12 s after body 201 replica 11.5–17 s 201 replica 12.11 s
|
||||
other path: replica silent 12 s 504 unavailable 9.5–12 s 504 LB application/json 10.01 s
|
||||
upload: replica silent 32 s 504 unavailable 29.5–32 s 504 LB application/json 30.11 s
|
||||
upload: client silent mid-body 400 invalid_request 29–33 s 400 LB application/json 30.02 s
|
||||
PASS: the upload path waits 30 s for the replica, other paths 10 s, LB errors are in the contract format
|
||||
exit=0
|
||||
```
|
||||
|
||||
- Реплика молчит 12 с до чтения тела и после него — клиент получает
|
||||
ответ реплики (201), а не 502/504 LB: `http-request set-timeout server
|
||||
30s` на пути `POST /api/v1/chats/{chat_id}/attachments`.
|
||||
- Другой путь (`GET /api/v1/users/me`) — по-прежнему 504 через 10 с:
|
||||
цепочка таймаутов лабы 3 не изменилась.
|
||||
- Реплика молчит 32 с на пути загрузки — 504 через 30 с.
|
||||
- Клиент отправил половину тела и замолчал — 400 `invalid_request` через
|
||||
30 с (`timeout client`) в формате контракта: `application/json`,
|
||||
ровно `{"error": {"code", "message", "request_id"}}`, `request_id` =
|
||||
`X-Request-Id` (`http-error status 400`).
|
||||
|
||||
## Конфигурация до change (`f894040`) — код 1
|
||||
|
||||
Конфигурация извлечена `git archive f894040 infra/haproxy/haproxy.cfg |
|
||||
tar -x -C <scratchpad>/lbto-old`.
|
||||
|
||||
```
|
||||
$ python3 .claude/skills/run-mtusi-messenger/driver.py lb-upload-timeouts --config <scratchpad>/lbto-old/infra/haproxy/haproxy.cfg
|
||||
config <scratchpad>/lbto-old/infra/haproxy/haproxy.cfg
|
||||
haproxy haproxy:3.4.6-trixie@sha256:e273915691a8eab3f105bf3e39fd4c29a4ecf334e33421903b5589d25e14db26, stub image mtusi-messenger:lab4, LB 127.0.0.1:65137
|
||||
haproxy -c: exit 0
|
||||
case expected got time
|
||||
upload: replica silent 12 s before body 201 replica 11.5–17 s 502 LB application/json 10.28 s FAIL: status 502
|
||||
upload: replica silent 12 s after body 201 replica 11.5–17 s 504 LB application/json 10.10 s FAIL: status 504
|
||||
other path: replica silent 12 s 504 unavailable 9.5–12 s 504 LB application/json 10.00 s
|
||||
upload: replica silent 32 s 504 unavailable 29.5–32 s 504 LB application/json 10.10 s FAIL: time 10.10 s
|
||||
upload: client silent mid-body 400 invalid_request 29–33 s 400 LB text/html 30.02 s FAIL: Content-Type text/html
|
||||
FAIL: 4 case(s) differ
|
||||
exit=1
|
||||
```
|
||||
|
||||
До change живая загрузка, которая молчит дольше 10 с до тела или после
|
||||
него, получала 502/504 от LB, хотя API ещё довёл бы её до конца, а
|
||||
клиенту, замолчавшему посреди тела, LB отвечал страницей HAProxy в HTML.
|
||||
Команда проверяет поведение конфигурации, а не только `haproxy -c`:
|
||||
синтаксис обеих верен.
|
||||
@@ -0,0 +1,82 @@
|
||||
# Медленные загрузки во время `make rolling_update`
|
||||
|
||||
- Дата: 2026-10-22, 12:24:06–12:24:39 UTC.
|
||||
- Commit: `ce1ae2c` (код и LB — `97a4be4`, change `upload-memory`).
|
||||
- Спек `load-balancing`, «Вывод реплики из балансировщика перед
|
||||
остановкой», сценарий «Загрузка во время дренажа»; design change
|
||||
`upload-memory`, решение 7: `ROLLOUT_DRAIN_TIMEOUT` 90 с — больше
|
||||
`timeout server` пути загрузки (30 с) и наибольшей длительности
|
||||
загрузки (≈ 73 с).
|
||||
- Стенд: рабочий `mtusi-lab4`, две реплики API за HAProxy. **LB на
|
||||
`127.0.0.1:8090`, а не на 8080 из `.env`**: порт 8080 хоста занят
|
||||
контейнером другого проекта (`domains-api-1`), LB поднят разово
|
||||
`APP_OUT_PORT=8090 docker compose up -d --force-recreate --no-deps
|
||||
haproxy`; `.env` не менялся. `make rolling_update` LB не пересоздаёт.
|
||||
|
||||
Разовый скрипт `rollout_upload.py` (scratchpad, httpx и `images.py`
|
||||
набора `student-tests`): синтетические пользователь и чат; две загрузки
|
||||
настоящего PNG из шума (1 048 276 байт) стартуют одновременно за
|
||||
`threading.Barrier`, у каждой своё соединение — round-robin LB отдаёт
|
||||
их разным репликам. Тело идёт 40 частями без `Content-Length`: первая
|
||||
загрузка ~20 с, вторая ~26 с (меньше срока тела 30 с). Через 4 с после
|
||||
старта — `make rolling_update`. После ответа оригинал скачивается и
|
||||
сверяется по SHA-256.
|
||||
|
||||
## До
|
||||
|
||||
```
|
||||
mtusi-lab4-api-17 ab84c041e373 Up 6 hours (healthy) 8080/tcp
|
||||
mtusi-lab4-api-18 37223e9a9593 Up 6 hours (healthy) 8080/tcp
|
||||
mtusi-lab4-haproxy-1 4c709887f9e4 Up 6 hours (healthy) 127.0.0.1:8090->8080/tcp
|
||||
```
|
||||
|
||||
## Ход (строки скрипта загрузок и `scripts/rolling-update.sh` по времени)
|
||||
|
||||
```
|
||||
12:24:06.818Z upload 1: sending 1048276 bytes over ~20 s
|
||||
12:24:06.818Z upload 2: sending 1048276 bytes over ~26 s
|
||||
12:24:11 rolling-update: start: 2 replicas ab84c041e373 37223e9a9593, image mtusi-messenger:lab4 from working tree
|
||||
12:24:14 rolling-update: build done in 3s
|
||||
12:24:16 rolling-update: migrate done in 2s
|
||||
12:24:16 rolling-update: replica 1/2: started new 3b96c600b25a
|
||||
12:24:19 rolling-update: replica 1/2: new 3b96c600b25a addr 192.168.0.9 slot api-3 UP in 3s
|
||||
12:24:19 rolling-update: replica 1/2: drain old ab84c041e373 addr 192.168.0.6 slot api-1
|
||||
12:24:27.010Z upload 1: 201 in 20.2 s, X-Instance-Id 37223e9a9593, sha256 of download matches: True
|
||||
12:24:33 rolling-update: replica 1/2: old ab84c041e373 idle after 14s
|
||||
12:24:33.012Z upload 2: 201 in 26.2 s, X-Instance-Id ab84c041e373, sha256 of download matches: True
|
||||
different replicas: True
|
||||
upload script exit=0
|
||||
12:24:33 rolling-update: replica 1/2: maint slot api-1, stopping old ab84c041e373
|
||||
12:24:33 rolling-update: replica 1/2: removed old ab84c041e373 (stop 0s, exit 0)
|
||||
12:24:33 rolling-update: replica 1/2: slot api-1 ready
|
||||
12:24:34 rolling-update: replica 2/2: started new f6915f9b80dc
|
||||
12:24:37 rolling-update: replica 2/2: new f6915f9b80dc addr 192.168.0.6 slot api-1 UP in 4s
|
||||
12:24:37 rolling-update: replica 2/2: drain old 37223e9a9593 addr 192.168.0.5 slot api-2
|
||||
12:24:37 rolling-update: replica 2/2: old 37223e9a9593 idle after 0s
|
||||
12:24:37 rolling-update: replica 2/2: maint slot api-2, stopping old 37223e9a9593
|
||||
12:24:37 rolling-update: replica 2/2: removed old 37223e9a9593 (stop 0s, exit 0)
|
||||
12:24:38 rolling-update: replica 2/2: slot api-2 ready
|
||||
12:24:39 rolling-update: done: 2 replicas 3b96c600b25a f6915f9b80dc UP in 28s
|
||||
```
|
||||
|
||||
## После
|
||||
|
||||
```
|
||||
mtusi-lab4-api-19 3b96c600b25a Up 22 seconds (healthy) 8080/tcp
|
||||
mtusi-lab4-api-20 f6915f9b80dc Up 5 seconds (healthy) 8080/tcp
|
||||
mtusi-lab4-haproxy-1 4c709887f9e4 Up 6 hours (healthy) 127.0.0.1:8090->8080/tcp
|
||||
```
|
||||
|
||||
## Вывод
|
||||
|
||||
- Загрузка 2 шла на `ab84c041e373`, которую замена вывела из LB в
|
||||
12:24:19 (`drain`), — через 12 с после начала тела. Дренаж ждал её
|
||||
14 с (`idle after 14s`), загрузка получила 201 от той же реплики в
|
||||
12:24:33.012, и только затем — `maint` и `docker stop` (код 0).
|
||||
Оригинал скачивается с тем же SHA-256. При прежнем сроке дренажа 12 с
|
||||
замена остановила бы реплику посреди загрузки.
|
||||
- Загрузка 1 шла на `37223e9a9593` и закончилась 201 в 12:24:27, раньше,
|
||||
чем дошла очередь второй реплики (её дренаж — 12:24:37, `idle after
|
||||
0s`): обе реплики приняли по загрузке, обе 201, а сценарий «Загрузка
|
||||
во время дренажа» показан на первой заменяемой реплике.
|
||||
- Замена — 28 с, в конце две новые реплики `UP`, LB не пересоздавался.
|
||||
Reference in New Issue
Block a user