Repository navigation
fix(adonet): prevent SQLite transaction leaks - #11354
ReubenBond merged 6 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation addresses the transaction leak while preserving write-version semantics and adds focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes SQLite transaction leaks during contended ADO.NET grain-state writes.
Changes:
- Replaces explicit transactions with an atomic trigger-driven write.
- Adds pooled-connection contention and durability coverage.
| File | Description |
|---|---|
src/AdoNet/Orleans.Persistence.AdoNet/Sqlite-Persistence.sql |
Stages writes in a temporary table and applies them through a trigger. |
test/Extensions/Orleans.AdoNet.Tests/Persistence/SqlitePersistenceQueryTests.cs |
Verifies failed writes do not poison pooled connections. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
7157083 to
44dbaa2
Compare
Code coverage
Report-only conclusion: current-main baseline stale. The newest successful coverage run tested a1a4676, not current main d4e4620. Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
Fixes #11350.
Problem
SQLite
WriteToStorageKeyopened a transaction using command-textBEGIN TRANSACTION. Writer contention could stop the batch beforeCOMMIT, returning an untracked open transaction to theMicrosoft.Data.Sqliteconnection pool. Reusing that connection caused later writes to fail and allowed clears to be acknowledged without becoming durable.Solution
Stage each write in a connection-private TEMP table and apply the mutation and version bookkeeping through a TEMP trigger. The request insertion and trigger effects execute as one implicit transaction; subsequent statements only read the TEMP result. Preserve optimistic-concurrency, full-identity matching, and scalar-version semantics.
Make the original SQLite main and persistence scripts idempotent so operators can reapply them to refresh all three persistence queries while preserving grain state. Add focused regression coverage for pooled-connection contention, durable clears, version progression, and script reapplication.
Rationale
A single-statement mutation avoids leaking explicit transactions and prevents a trailing write-lock failure after a durable mutation. Reapplying the original scripts installs the corrected queries while keeping database setup and upgrade timing under application control.