fix(objectql): robust multi-write transactions (ambient transaction) + cross-object batch (#1604)#1607
Merged
Merged
Conversation
…deadlock Root cause (ADR-0034): engine.transaction() threaded the open transaction only into the top-level write's driver options; internal queries during a write (reference checks, hooks, expand) asked the pool for another connection and deadlocked on SQLite's single-connection pool — wedging the connection. Fix: an AsyncLocalStorage ambient transaction store. While a transaction() callback runs, the active transaction lives in the store; buildDriverOptions falls back to it, so EVERY data op (even one given no explicit context) binds to the same connection. Explicit context still wins. Both ObjectQL.transaction and ScopedContext.transaction set the store. Also adds the cross-object transactional batch endpoint (POST /batch, issue #1604) with intra-batch $ref parent references, now that multi-write is safe. Tests: engine ambient-transaction guard + driver multi-write commit/rollback guard. Full suites green (objectql 521, rest 88, driver-sql 137). Verified end-to-end: master-detail atomic create + rollback + no connection wedge. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Implements ADR-0034, unblocks #1604. Root cause: engine.transaction() threaded the transaction only into the top-level write; internal queries during a write grabbed another pool connection and deadlocked on SQLite's single-connection pool. Fix: AsyncLocalStorage ambient transaction — buildDriverOptions falls back to it so every data op binds to the same connection. Plus POST /api/v1/data/batch (cross-object, $ref parent refs). Tests: engine + driver multi-write guards; objectql 521 / rest 88 / driver-sql 137 green; verified e2e (atomic create + rollback + no wedge).
🤖 Generated with Claude Code