fix: delete the object and the row in one locked cleanup transaction

Keep the committed mark, then delete the object and the row under the
same row lock, so an older replica without the mark check that waits on
the row finds it gone instead of promoting it to ready after the object
delete. A mixed-version stand is no worse than before the mark; document
the upgrade order (replicas first, cleaner last) and fix stale wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 22:08:29 +03:00
co-authored by Claude Opus 5.5
parent 6551839807
commit 5889ca2ad7
13 changed files with 384 additions and 136 deletions
+5 -1
View File
@@ -64,7 +64,11 @@ paths:
держат), `mark_removing` (пометка к уборке: `updated_at` = время
уборщика, позже `created_at`; без миграции, CHECK
`updated_after_created` выполняется), `delete_attachment`
(`RETURNING id`, `bool`); DTO — `AttachmentInListDTO`. Статус в этих выражениях — константа
(`RETURNING id`, `bool`); DTO — `AttachmentInListDTO`. Порядок
вызовов — в сервисе (`service-layer.md`), два шага: транзакция
`lock_stale_pending` → `mark_removing`, затем транзакция
`lock_stale_pending` → `delete_original` → `delete_attachment`.
Статус в этих выражениях — константа
(`literal(..., literal_execute=True)`), а не параметр: условие
частичного индекса `ix_attachments_pending_created_at` планировщик
доказывает только по константе, и общий план подготовленного