# Ревизии `c7e2f1a04b56` и `d3f9a6b2c1e7`: проба, откат на прежний образ и возврат - Дата: 2026-10-31, 13:38–13:42 UTC - Commit: `e2a6427` (ветка `feat/pipeline-reliability`), рабочее дерево без правок кода (добавлены только файлы `evidence/`) - Стенд: проект compose `mtusi-lab5`; проба — на временной базе `pl_migprobe` в контейнере `postgres` (`DATABASE__NAME` в окружении `uv run alembic`, в конце `DROP DATABASE`), строки синтетические - Спеки: `db-migrations`, `data-storage`; design change `pipeline-reliability`, решение 10 и Migration Plan - Вывод сокращён: убраны строки `DETAIL` с синтетическими значениями и предупреждения alembic, из итога `make reconcile` — служебные поля ## Проба ревизий на временной базе С нуля, `alembic check`, повтор, откат, снова `upgrade`; строки прежней ревизии; ограничения; планы выборок relay и уборщика в общем плане (`force_generic_plan`) на 208 тыс. заданий, из них 8 тыс. живых; транзакция держит `attachment_jobs` дольше 2 с — первая ревизия падает без изменений, повтор проходит. ```text CREATE DATABASE --- from scratch, check, repeat, downgrade -2, upgrade alembic upgrade head: exit 0 d3f9a6b2c1e7 (head) alembic current: exit 0 No new upgrade operations detected. alembic check: exit 0 alembic upgrade head: exit 0 alembic downgrade -2: exit 0 a1d4c7e90b23 alembic current: exit 0 alembic upgrade head: exit 0 d3f9a6b2c1e7 (head) alembic current: exit 0 --- rows of the previous revision, then upgrade alembic downgrade -2: exit 0 INSERT 0 2 INSERT 0 1 alembic upgrade head: exit 0 job of the previous level: id | state | attempt | attempt_base 55555555-5555-4555-8555-555555555551|queued|0|0 insert of a job without attempt_base: INSERT 0 1 convalidated of the new CHECK: ck_attachment_jobs_attempt_base|f indisvalid of the four indexes: ix_attachment_jobs_lease|t ix_attachment_jobs_outbox|t ix_attachment_jobs_published|t ix_attachments_staging_cleanup|t --- constraints audit record of an unknown job: ERROR: insert or update on table "attachment_job_replays" violates foreign key constraint "fk_attachment_job_replays_job_id_attachment_jobs" attempt_base greater than attempt: ERROR: new row for relation "attachment_jobs" violates check constraint "ck_attachment_jobs_attempt_base" INSERT 0 1 delete of a job with an audit record: ERROR: update or delete on table "attachment_jobs" violates foreign key constraint "fk_attachment_job_replays_job_id_attachment_jobs" on table "attachment_job_replays" --- filled database: 208 000 jobs, 8 000 live INSERT 0 208000 INSERT 0 208000 VACUUM VACUUM processing|2666 queued|5335 succeeded|200001 --- relay: due intents, generic plan Limit (actual rows=100.00 loops=1) Buffers: shared hit=302 -> LockRows (actual rows=100.00 loops=1) Buffers: shared hit=302 -> Index Scan using ix_attachment_jobs_outbox on attachment_jobs (actual rows=100.00 loops=1) Index Cond: (COALESCE(next_attempt_at, created_at) <= $1) Filter: ((published_at IS NULL) AND (state = 'queued'::text)) Index Searches: 1 Buffers: shared hit=102 Planning Time: 0.116 ms Execution Time: 0.132 ms --- relay: expired leases, generic plan Limit (actual rows=0.00 loops=1) Buffers: shared hit=2 -> LockRows (actual rows=0.00 loops=1) Buffers: shared hit=2 -> Index Scan using ix_attachment_jobs_lease on attachment_jobs (actual rows=0.00 loops=1) Index Cond: (lease_expires_at < $1) Filter: (state = 'processing'::text) Index Searches: 1 Buffers: shared hit=2 Planning Time: 0.032 ms Execution Time: 0.007 ms --- relay: count of published Aggregate (actual rows=1.00 loops=1) Buffers: shared hit=5 -> Index Only Scan using ix_attachment_jobs_published on attachment_jobs (actual rows=2667.00 loops=1) Heap Fetches: 0 Index Searches: 1 Buffers: shared hit=5 Planning Time: 0.032 ms Execution Time: 0.128 ms --- cleaner: staging candidates, generic plan Limit (actual rows=100.00 loops=1) Buffers: shared hit=97 -> Index Scan using ix_attachments_staging_cleanup on attachments (actual rows=100.00 loops=1) Index Cond: ((status = 'ready'::text) AND (updated_at < $1)) Index Searches: 1 Buffers: shared hit=97 Planning Time: 0.123 ms Execution Time: 0.127 ms --- lock_timeout: a transaction holds attachment_jobs longer than 2 s alembic downgrade -2: exit 0 asyncpg.exceptions.LockNotAvailableError: canceling statement due to lock timeout alembic upgrade head: exit 1 upgrade under lock took 3 s a1d4c7e90b23 alembic current: exit 0 attempt_base columns after the failure: 0 alembic upgrade head: exit 0 d3f9a6b2c1e7 (head) alembic current: exit 0 DROP DATABASE cleanup done ``` ## Откат на образ `7f38948` и возврат Команды по Migration Plan design: откат реплик с `infra/rollback/broker.compose.yml` (прежний код публикует сам, ему нужен адрес и пароль брокера), прежние worker и уборщик, relay остановлен; затем вперёд: `s3-bootstrap`, `make rolling_update`, worker и уборщик, relay. Схема остаётся новой. Смесь версий, в отличие от перехода уровня 3, не даёт 500: новых статусов и `error_code` нет. ```text upload on the current code: 202 ready variants ['crop', 'optimized', 'thumbnail'] --- rollback: replicas on 7f38948 with the broker override, previous worker and cleaner, relay stopped $ make rolling_update COMMIT=7f38948 MIGRATE=0 COMPOSE_FILE=docker-compose.yml:infra/rollback/broker.compose.yml: exit 0, 11 s $ docker compose up -d --no-deps worker cleaner: exit 0, 1 s $ docker compose stop relay: exit 0, 0 s $ make test: exit 0, 1 s PASS: lab5 public API scenario; infrastructure and grading evidence remain separate. --- previous image on the new schema row of the new code: metadata 200, ready, variants ['crop', 'optimized', 'thumbnail'] content original: 200 content thumbnail: 200 content crop: 200 content optimized: 200 message with the row of the new code: 201 history: 200 upload on the previous image: 202 ready variants ['thumbnail'] --- forward by the plan: s3-bootstrap, rolling_update, worker and cleaner, relay $ docker compose up -d s3-bootstrap: exit 0, 1 s $ make rolling_update: exit 0, 13 s $ docker compose up -d --no-deps worker cleaner: exit 0, 1 s $ docker compose up -d --no-deps relay: exit 0, 0 s $ make lb_stats: exit 0, 0 s svname addr status check_status scur stot econ wretr wredis hrsp_5xx api-1 172.31.0.6:8080 UP L7OK 0 1259 0 0 1 0 api-3 172.31.0.11:8080 UP L7OK 0 26 0 0 0 0 --- current code again new upload: 202 ready variants ['crop', 'optimized', 'thumbnail'] attachment of the previous image: ready variants ['thumbnail'] content original: 200 content thumbnail: 200 content crop: 404 content optimized: 404 make reconcile: exit 0 found: {} fixed: {} listed_objects: 6792 checked_rows: 2534 old attachment named by reconcile: False ``` После пробы реплики, worker, relay и уборщик на одном образе текущего кода: метка `com.docker.compose.image` у них одна (`.claude/rules/docker.md`).