Repository navigation
Prevent automatic queued messages from overtaking a pending send - #6247
Merged
Merged
Conversation
ymichael
added a commit
that referenced
this pull request
Oct 24, 2026
## Human comments ## What was wrong Every integration harness reran database migrations and rebuilt the same scripted-echo provider artifact. The Linux integration job also used only two Vitest workers on its four-vCPU runner. Together these repeated setup costs and limited concurrency lengthened a job that was among the remaining CI bottlenecks. ## What changed - Build one SQLite template with the real migrations, copy a fresh database for every harness, and initialize its personal project separately. Global setup returns the template cleanup callback. - Reuse the immutable scripted-echo build promise per worker. Each harness still creates a fresh registry, server, daemon, provider processes, and sessions. - Use four workers in the existing Linux integration job. Keep the Windows worker count unchanged because the measured four-worker variant was slower. These are test-support and CI changes. No production code, assertions, test selection, cache invalidation rules, shard counts, or timeouts change. ## How you verified [Controlled benchmark](https://github.com/get-bb/bb/actions/runs/40137507494): baseline, fixture reuse, and fixture reuse with four workers; two replicas on each four-vCPU Linux/Windows runner type, Node 22, empty Turbo caches. All 12 jobs passed the same 77 tests across 28 files. | Integration test task | Baseline, two runs | Fixture reuse | Fixture reuse + four workers | | --- | --- | --- | --- | | Linux | 46.53s / 39.16s | 34.40s / 33.11s | 27.13s / 24.77s | | Windows | 65.66s / 42.54s | 42.92s / 41.64s | 54.23s / 68.06s | Linux mean test-task time falls from 42.8s to 26.0s, about 39%. The complete Linux command, including upstream tasks, falls from 40.5–48.1s to 26.0–28.4s. Windows timings are noisier, so these runs do not establish a precise percentage gain; its current worker count is retained. These are integration-job measurements, not whole-pipeline percentages. Local full integration runs with three workers passed 77/77 in 39.39s baseline, 36.36s with database reuse, and 34.28s with database plus provider fixture reuse. Turbo lint/typecheck, formatting, diff checks, and actionlint passed (excluding existing custom Blacksmith runner labels). Real-provider suite setup/discovery passed; all 11 live-provider cases were deliberately filtered out, so no live-provider execution is claimed. Independent review found no issues: the database helper preserves connection defaults and real schema, existing database tests cover template-copy isolation, direct server initDb coverage remains, and no tests/assertions were removed. The first final-head CI attempt passed every check except Linux server shard 2, which hit `queued_message_claim_lost` in the unchanged `keeps queued choices separate until dispatch and preserves the next row` test. Its server worker count and executed provider-registration path are unchanged. All 39 cases passed against the baseline helper in 11 focused runs; the separate CI reliability thread then reproduced the production race deterministically on the baseline by pausing the older send while a competing drain claims the newer row. That fix is tracked in [#6247](#6247). Only the failed shard was rerun on the unchanged head. Final-head [CI is green](https://github.com/get-bb/bb/actions/runs/40137789809/attempts/2) on `46241a7b06c7572dee5530707e0243e804a9918d`; the passing retry does not fix the queue race. The benchmark workflow lives on a separate branch and is excluded from this PR. > AGENT GENERATED
mistakeknot
added a commit
to mistakeknot/aleph
that referenced
this pull request
Oct 27, 2026
Backport five upstream bb fixes (get-bb#6247, get-bb#6255, get-bb#6243, get-bb#6334, get-bb#6358)
2 of 13 tasks
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
CI 40137789809 failed while dispatching an older queued message:
Queued message claim expired before it could be sent. The claim had not expired. While that message prepared its command asynchronously, an automatic drain skipped its claimed row, claimed a later message, and activated the thread first. The older send then failed its lifecycle transition. This can reorder queued messages and produce a spurious send conflict in production.What changed
Production change: inside both immediate automatic-claim transactions, reuse the existing per-thread claimed-message query to decline another automatic claim until the current dispatch finishes or releases its claim. Explicit send-now policy is unchanged. No schema, wire, SDK, CLI, timeout, CI selection, cache, or shard changes.
Extend the existing service-tier regression to hold real command preparation, run a competing next-group or targeted automatic claim, and then release preparation. It retains the queue snapshots and execution-tier assertions and checks that exactly one command was dispatched. The edit-hold database fixture now consumes its first claimed dispatch before checking the second row's expired hold; its existing assertions remain intact.
How you verified
queued-messages.ts:605, matching CI, and pass with the fix.git diff --checkpass. Reviewed againstdocs/CODE_REVIEW.mdand deslop guidance.0e449d8b5a, including both Linux server shards, all three Windows server shards, Linux/Windows integration, foundation packages, lint/typecheck, and checks.