Repository navigation
fix(session): settle unexpected commit worker failures - #5772
Conversation
…l task errors (volcengine#5622) on_dequeue only guarded _parse_message; any exception raised inside _process — e.g. the json.JSONDecodeError from Session.load() reading a torn line of the live messages.jsonl during a compact commit — escaped the handler. The queue layer then swallowed it: the delivery was never acked, the queue row stayed in processing, and the task record stayed pending until the client gave up with "Phase 2 timed out". A worker restart replays the same payload into the same race, so recovery never completes on its own. Wrap the _process call and mirror the existing session-missing branch: reuse the Phase-1 task record (tracker.create is idempotent for an explicit task_id owned by the same user), record the real error via tracker.fail, and settle the delivery as ProcessResult.failed so clients see the underlying crash instead of a timeout. Out of scope (noted in the PR): locking Session.load() against the Phase-1 drain-rewrite, switching Phase 2 to the immutable archive, and client timeout semantics.
|
I ran this branch through the production wiring (real
I have a branch with that state check and a test for the redelivered |
Reuse queue-owned failure settlement and predecessor recovery instead of duplicating task mutations in the processor. Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com>
…l task errors (#5622) (#5772) on_dequeue only guarded _parse_message; any exception raised inside _process — e.g. the json.JSONDecodeError from Session.load() reading a torn line of the live messages.jsonl during a compact commit — escaped the handler. The queue layer then swallowed it: the delivery was never acked, the queue row stayed in processing, and the task record stayed pending until the client gave up with "Phase 2 timed out". A worker restart replays the same payload into the same race, so recovery never completes on its own. Wrap the _process call and mirror the existing session-missing branch: reuse the Phase-1 task record (tracker.create is idempotent for an explicit task_id owned by the same user), record the real error via tracker.fail, and settle the delivery as ProcessResult.failed so clients see the underlying crash instead of a timeout. Out of scope (noted in the PR): locking Session.load() against the Phase-1 drain-rewrite, switching Phase 2 to the immutable archive, and client timeout semantics. Co-authored-by: qin-ptr <222410531+qin-ptr@users.noreply.github.com> Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com> (cherry picked from commit e24295f)
…l task errors (#5622) (#5772) on_dequeue only guarded _parse_message; any exception raised inside _process — e.g. the json.JSONDecodeError from Session.load() reading a torn line of the live messages.jsonl during a compact commit — escaped the handler. The queue layer then swallowed it: the delivery was never acked, the queue row stayed in processing, and the task record stayed pending until the client gave up with "Phase 2 timed out". A worker restart replays the same payload into the same race, so recovery never completes on its own. Wrap the _process call and mirror the existing session-missing branch: reuse the Phase-1 task record (tracker.create is idempotent for an explicit task_id owned by the same user), record the real error via tracker.fail, and settle the delivery as ProcessResult.failed so clients see the underlying crash instead of a timeout. Out of scope (noted in the PR): locking Session.load() against the Phase-1 drain-rewrite, switching Phase 2 to the immutable archive, and client timeout semantics. Co-authored-by: qin-ptr <222410531+qin-ptr@users.noreply.github.com> Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com> (cherry picked from commit e24295f)
Description
If loading a Session raises a JSON parsing error, the commit worker currently exits without settling its queue delivery. The task remains pending and later archives wait behind it.
Return a failed queue result for an unexpected processor exception. The existing task middleware persists the error and settles the delivery; the existing predecessor recovery then allows the next archive to run. The final change is one file, +4/-1 lines.
Before: a Session load error leaves the task pending, the delivery unacknowledged, and the next archive blocked.
After: the same error produces a failed task with the original error, the delivery is acknowledged, and the next archive proceeds through existing predecessor recovery.
Human Involvement
Related Issue
Fixes #5622
Type of Change
Changes Made
_processexceptions intoProcessResult.failed, using the existing queue lifecycle to update task state and acknowledge the delivery.Testing
40 existing tests passed across the SessionCommit processor, QueueManager, commit resume, and task-work contracts. Ruff check and format check passed.
A focused before/after fault-injection probe used the real Session, NamedQueue, TaskWorkQueueMiddleware, TaskTracker, and PersistentTaskStore with in-memory storage transports. A load error leaves the baseline task pending and its successor blocked. With this change, the task fails with the original error, its delivery is acknowledged, and the next archive completes. Both a warm tracker and a tracker reloaded from persisted task records passed. No new test files or unit tests are added.
Checklist
Screenshots (if applicable)
Not applicable.
Additional Notes
This settles the reported failure path. The concurrent torn-read cause has not been reproduced. Archive failure markers continue to be supplied by the existing predecessor recovery when the next archive checks the failed predecessor; this change does not introduce a second finalization mechanism.