Repository navigation
fix(libsql): serialize Factory writes on shared clients - #20278
Conversation
Route Factory transactions and autocommit operations through the existing per-client write queue. This prevents concurrent dispatcher claims and other shared-client writes from colliding with open LibSQL transactions or being rolled back with unrelated work. Add file-backed regression coverage for concurrent Factory transactions and writes racing a rollback. Co-Authored-By: Mastra Code (openai/gpt-5.6-sol) <noreply@mastra.ai>
🦋 Changeset detectedLatest commit: cd6f096 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR triageLinked issue check skipped for core contributor @wardpeet. PR complexity score
Applied label: Changed test gateChanged Test Gate is pending. The |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughChangesLibSQL write serialization
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Factory storage shares a LibSQL client with the wrapped Mastra store, but its transactions and autocommit writes previously used a separate lock domain. Concurrent dispatcher claims could therefore collide with an open write transaction and report
SQLITE_BUSY, while unrelated writes could also be swept into its commit or rollback.Before, Factory writes used a private mutex only for
updateAtomic(). After this change, complete Factory write operations, transactions, and schema updates use the existing per-client write queue. Transaction-scoped operations bypass recursive acquisition while the outer transaction owns the queue.Added file-backed regression coverage for concurrent Factory transactions, Factory writes racing a rollback, and wrapped Mastra-domain writes sharing the client. Verified with the full
@mastra/libsqlsuite (905 passed, 19 skipped), its TypeScript check, build, lint, andgit diff --check.ELI5
This PR makes shared LibSQL writes take turns instead of happening at the same time. This prevents transactions and other writes from interfering with each other and causing database lock errors.
What changed
@mastra/libsql.Validation
@mastra/libsqlsuite: 905 passed, 19 skippedgit diff --checkpassed