Repository navigation
Cache prepared statements for event persistence and pruning - #8449
Merged
Merged
Conversation
scowalt
pushed a commit
to scowalt/bb
that referenced
this pull request
Dec 1, 2026
) 🚨 **SLOP COP** 🚨 · `new-issue-autopilot` ## Human comments ## What was wrong Fixed-shape event and pruning writes bypassed the database's per-connection prepared-query cache. Each persisted event synchronously prepared its insert and pruning marker again, even on warm connections and across successive transactions. The [verified reproduction report](https://get-bb.github.io/reports/issues/8437.html) records matching failures in two clean trusted-main checkouts. ## What changed - Cache the strict and duplicate-tolerant event insert variants, binding every event field at execution time. - Cache pending and policy-specific pruning inserts while retaining revision increments and transaction-shared statement reuse. - Add four real-database regression cases covering different threads and payloads, duplicate imports, and root/transaction connections. The change stays in `packages/db`: **3 files, 215 changed text lines (189 additions + 26 deletions)**. No dependency, generated file, migration, stored-data rewrite, or public protocol/API change. ## How you verified - Before the fix, all four new regression cases fail on unchanged trusted main; a second clean checkout reproduces identical warm prepare counts of **12 / 18 / 6 / 6**. - After the fix, all four cases pass with **zero** warm prepares, while checking stored payloads, duplicate suppression, and pruning revisions. - `pnpm exec turbo run test --filter=@bb/db -- --run test/data/event-write-preparation.test.ts test/data/events.test.ts test/data/thread-pruning.test.ts test/data/retained-event-outputs.test.ts test/data/resolved-item-pruning-resume.test.ts`: **163 tests passed**. - `pnpm exec turbo run typecheck --filter=@bb/db` and `git diff --check origin/main`: passed. - Broad database suite: **785 tests passed**, but the queued-message suite's existing correlated-subquery query-plan guard fails. The same guard failure reproduces on unchanged main in the second checkout, with all 47 queued-message tests passing. It is not changed or suppressed here. - The broad build encounters an existing GitHub plugin SDK-dist build-order failure. Scoped database dependency build, typecheck, and relevant tests succeed. Fixes get-bb#8437 > AGENT GENERATED <!-- slopcop:rule=new-issue-autopilot run=run_lrnsnylkmx45zyay sha=issue-8437 kind=summary --> Co-authored-by: SawyerHood <[email protected]>
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.
🚨 SLOP COP 🚨 ·
new-issue-autopilotHuman comments
What was wrong
Fixed-shape event and pruning writes bypassed the database's per-connection prepared-query cache. Each persisted event synchronously prepared its insert and pruning marker again, even on warm connections and across successive transactions. The verified reproduction report records matching failures in two clean trusted-main checkouts.
What changed
The change stays in
packages/db: 3 files, 215 changed text lines (189 additions + 26 deletions). No dependency, generated file, migration, stored-data rewrite, or public protocol/API change.How you verified
pnpm exec turbo run test --filter=@bb/db -- --run test/data/event-write-preparation.test.ts test/data/events.test.ts test/data/thread-pruning.test.ts test/data/retained-event-outputs.test.ts test/data/resolved-item-pruning-resume.test.ts: 163 tests passed.pnpm exec turbo run typecheck --filter=@bb/dbandgit diff --check origin/main: passed.Fixes #8437