Repository navigation
fix(platform): queue a comment's retry on the audit chain it ends on - #3980
Conversation
A comment write that lost before its audit append, on a read/write dependency with the org's other comment writes, carried the task's queue key alone. Its retry then lost again at the org's audit chain head. A burst of commenters across one org's tasks spent up to three attempts a writer, and now and then one ran out of attempts and the comment failed. Adding and deleting a comment now mark a serialization failure with the chain head's key as well, so the retry holds both queues from before its snapshot and wastes at most one attempt.
|
Independent review at The raw source-bound real-Postgres burst receipts requested on TALE-382 remain the last evidence handoff before merge. Please qualify the PR body’s “at most one attempt” statement to the observed burst/covered statement-failure path: this wrapper does not establish a universal bound for failures raised at transaction commit or every possible source of contention. No broader retry guarantee is claimed by this review. |
Summary
A burst of comment writes across one organization's tasks could lose a comment: its writer ran out of its five serializable attempts and failed with
40001. I found this while running the wholebackend:integrationsuite for TALE-382. Thetasks: a burst of serializable commenters across one org's tasks all landcheck was red or flaky onmain.Root cause. A comment write can fail before its audit append, on a read/write dependency with the org's other comment writes. Postgres reports these as
Canceled on identification as a pivotwherever it finds one. Such a failure carried only the task's retry-queue key, so the retry queued on the task alone and then lost a second time at the org's audit-chain head, a write-write conflict. A writer could spend three attempts or more. Only a loss at the head carried both keys.Change.
addTaskCommentanddeleteTaskCommentnow go throughqueuedCommentWrite. It marks a serialization failure anywhere in the write with the chain head's key too (auditChainQueueKey). The retry then takes both session locks before its snapshot and wastes at most one attempt, which is what the lane and the queue's own doc claim. Refusals and other errors pass through unmarked.Checklist
bun run checkpasses — N/A locally: the sandbox's 4 GiB cap cannot hold the platform-wide gates. The changed files and their importers were checked as listed under Test plan, and CI runs the full gate.bun run lint:sastpasses — the pre-commit hook ran Opengrep on the staged files; CI's Opengrep job runs it in full.docs/{en,de,fr}/— N/A: no user-visible change.README.md— N/A.Test plan
[task-comment]only, and their retries then lost again ataudit_chain_heads.ITEST_LANES=checkTaskCommentBurst,checkTaskCommentCrossTaskBurst:landed=11/12 rejected=1 (could not serialize access due to read/write dependencies among transactions) attempts=27.attempts=23, both lanes pass.backend/domains/tasks/comments.queue.test.tshas 3 new cases: an add loss and a delete loss both carry[task, chain], and a refusal stays unmarked. The two marking cases fail onmain'scomments.ts.vitest --project serverover the 19 files that import the module: 253 tests pass.tscover the changed files: clean.oxlint --type-awareandoxfmt --check: clean.