StorageReconciler walks the sorted bucket listing and keyset pages of attachments ordered by object key side by side, so a pass is linear and keeps one page of each side in memory. An object without a row is deleted only when it is older than grace plus skew and a lookup by key right before the delete still finds no row; a ready row whose object is missing, has another size or, with the deep check, another digest is put in quarantine after a HEAD recheck and is never deleted; a stale intent is claimed with SKIP LOCKED and dropped object first; a quarantined row whose object matches again is released. Deep checks hash objects in a bounded task group, each action uses its own unit of work, and failures of single actions are counted instead of aborting. An advisory lock lets one pass run at a time. Content of a quarantined attachment answers 404 without touching S3, its metadata is unchanged. The storage port gains listing pages and HEAD, the repository keyset pages, lookup by key, claim and quarantine marking; the platform logger can write to another stream. The one-off entry point python -m messenger.attachments.entrypoints.reconcile is a dry run unless --apply is given, assembles the adapters with the API key of S3 and prints a JSON report with counts per class, samples and the cost of the pass to stdout while the journal goes to stderr. Tests run the reconciler against its own migrated database with every class, apply and repeat, the row that appears after the listing, the busy lock and the release, and check paged byte-order listing and HEAD against RustFS. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
3.6 KiB
3.6 KiB
1. Схема и миграции
- 1.1
0004_attachment_quarantine.sql:quarantine_reasonсCHECK,quarantined_at, согласованность пары - 1.2 Проверка группы:
make student-test(test_migrations.py: повтор без изменений)
2. Зона attachments: домен и приложение
- 2.1 Домен:
Quarantine, полеquarantineагрегата - 2.2 Порты:
StoredObject,ObjectStorage.listing/stat,AttachmentRepository.page_after/by_key/claim/mark,SingleRun; командаReconcileStorage - 2.3
StorageReconciler: слияние потоков, классы, повторные проверки, действия,--deepпод ограничением, отчётReconciliation - 2.4
OpenAttachment: карантин →404без S3 - 2.5 Проверка группы:
make lint
3. Зона attachments: адаптеры и точка входа
- 3.1 Адаптер S3: листинг страницами,
HEAD; адаптер PostgreSQL: колонка карантина, keyset, по ключу,SKIP LOCKED,UPDATEкарантина,PostgresSingleRun - 3.2 Платформа: поток журнала настраивается
- 3.3 CLI
messenger.attachments.entrypoints.reconcile: флаги, сборка адаптеров, JSON в stdout, коды выхода - 3.4 Проверка группы: API-тесты сверки против одноразового PostgreSQL (каждый класс в dry-run без изменений, apply и повтор = 0, свежее и используемое сохранены, строка появилась после листинга, карантин и
404,healed,--deep, занятая блокировка); тест адаптера против RustFS (порядок листинга, страницы,HEAD)
4. Стенд
- 4.1
compose.yaml: сервисreconciler(профильreconcile),cpusetиз переменных уs3,postgres,reconciler;.env.example - 4.2 Цели
make reconcile ARGS=…,make reconcile-demo,make reconcile-cost - 4.3 Проверка группы:
docker compose config --quiet,make up,make reconcile
5. Обвязка трека
- 5.1
scripts/reconcile-inject.shиscripts/reconcile_check.pyиз заготовки - 5.2
student-tests/tools/seed_storage.py: наполнение N объектов и строк в образе API - 5.3
scripts/reconcile_track.py:demo(внедрение, dry-run, apply ×2, безопасность,healed, нагрузка) иcost(снимок хоста, закрепление CPU, матрица N × режим × 3) - 5.4 Проверка группы:
make check(Python 3.9, JSON),make lint
6. Измерения
- 6.1
make reconcile-demoна чистом стенде →evidence/reconcile/ - 6.2
make reconcile-costна чистом стенде →evidence/reconcile/cost/ - 6.3 Проверка группы: критерии H1 и H2 из
design.md
7. Отчёт
- 7.1
REPORT.md: раздел трека 2 (гипотеза, методика, результаты, ограничения, выводы), строки трека в таблице доказательств и отказов;AGENTS.md - 7.2 Проверка группы:
make check,make lint,make student-test,make test,make test-persistence ACTION_SCRIPT=scripts/restart.sh,make test-failover ACTION_SCRIPT=scripts/stop-one.sh