Repository navigation
Recheck thread status before committing dispatch - #3718
Merged
Merged
Conversation
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
Concurrent sends could pass idle admission together. After one activated the thread, competing sends attempted an illegal lifecycle transition and lost their input. The transaction status recheck prevents that race, but initially also rejected reprovision's own transition to
starting, leaving no persisted provisioning request to advance. Reproduction report.What changed
Recheck thread status inside the request transaction before appending input or consuming claimed queue rows. If another send changed the status, retry admission so queue-mode input waits behind the winning send.
For reprovision, run admission before the
run.preparingtransition within the transaction that persists the request and provisioning context. Publish the status notification after success. Rejected admission leaves the thread and its events unchanged. Retain the concurrent queue-send regression and add a rejected-reprovision regression. No public API or daemon wire changes.How you verified
pnpm exec turbo run test --filter=@bb/server --concurrency=4 -- test/threads/thread-turn-dispatch.test.ts test/threads/thread-send-dispatch.test.ts test/public/public-thread-data.test.ts test/threads/thread-provisioning-recovery.test.ts test/threads/dispatch-hooks.test.ts test/threads/thread-send-error-recovery.test.ts --maxWorkers=4.git diff --checkpassed.0f7c68d4e6d188c3aa4bc7018ac89e8ada2fe9cd: full server and integration suites, all app and package tests, build/typecheck/lint, and Linux/macOS package smoke passed. All 14 applicable PR checks passed; two conditional checks were skipped.Fixes #3716