Repository navigation
Requeue sends that lose the run start race - #1
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Rapid back-to-back sends on an idle thread all pass admission against the same idle snapshot, and each then appends its client turn request in the same transaction that applies
run.started. The first request wins the lifecycle transition; every competing request hitsrequireThreadLifecycleEventApplied, which throws on the illegalrun.startedfromactive, rolling back its whole transaction — including the appended input. The send is silently lost rather than queued behind the active run. See get-bb#3716 and https://get-bb.github.io/reports/issues/3716.html.What changed
apps/server/src/services/threads/thread-send.ts: the start-mode transaction re-reads the thread and fails fast when its status moved since admission, and an unappliedrun.startedno longer raises the generic lifecycle error. Both paths raise a dedicated recoverablethread_status_changed_during_sendApiError(createThreadStatusChangedDuringSendError/isThreadStatusChangedDuringSendError).apps/server/src/services/threads/dispatch-attempt.ts:runDispatchAttemptcatches only that error and routes through the existingreattemptDispatchForThreadChangecheckpoint with the freshly read thread, so the losing send is re-decided against the now-active thread and queued. The rollback happens before delivery and before claimed queue rows are consumed, so no turn can be duplicated and queue claim atomicity is unchanged.No wire, CLI, or doc surfaces changed.
How you verified
concurrent idle dispatchinapps/server/test/threads/thread-send-dispatch.test.ts: four concurrentqueue-if-activesends on an idle thread must yield exactly onesent, threequeued, anactivethread, and all three inputs retained in the queue. On cleanmainit fails withThreadLifecycleEventNotAppliedError: ... no transition for run.started from status active; it passes with the fix.pnpm exec turbo run test --filter=@bb/server -- test/threads/thread-send-dispatch.test.ts test/threads/dispatch-hooks.test.ts test/threads/thread-send-error-recovery.test.ts→ 44 passed.pnpm exec turbo run typecheck --filter=@bb/server→ clean.@bb/serversuite: onlytest/app/install-machine-script.test.tsandtest/services/plugin-catalog/bb-official-generator.test.tsfail, and they fail identically on cleanmain(environment-dependent: uid/HOME and git committer history).Fixes get-bb#3716
Link to Devin session: https://app.devin.ai/sessions/e30f319968a14318aaf5608f96ff38c5
Open in Devin Desktop: https://app.devin.ai/desktop/session/e30f319968a14318aaf5608f96ff38c5?variant=devin
Requested by: @treesitter1