Skip to content

bindings/dotnet: support batches on embedded replicas - #8609

Open
awakecoding wants to merge 1 commit into
tursodatabase:mainfrom
awakecoding:copilot/dotnet-replica-batches
Open

bindings/dotnet: support batches on embedded replicas#8609
awakecoding wants to merge 1 commit into
tursodatabase:mainfrom
awakecoding:copilot/dotnet-replica-batches

Conversation

@awakecoding

Copy link
Copy Markdown
Contributor

Summary

  • enable DbBatch on opened embedded replica connections while leaving plain local connections unsupported
  • execute replica batch commands sequentially through the existing TursoCommand path, including parameters, timeouts, cancellation, transactions, affected-row counts, scalar results, and ordered NextResult readers
  • keep active replica batch readers inside the sync-operation lifetime gate so sync and connection shutdown cannot race them
  • preserve direct remote batching and never replay a possibly partially applied batch; an expired batch stream is cleared and the original error is propagated

Semantics

Replica batches are sequential, not implicitly atomic. Callers must attach an explicit TursoTransaction when all commands need to commit or roll back together. The README now shows that pattern.

Extraction

This is the next focused extraction from the closed source draft #8504 (awakecoding:copilot/complete-dotnet-bindings, source commit f3b327655768d14a8da94c54db9fd3d98c4a7d3d) after merged PRs #8514, #8519, #8523, #8530, #8555, and #8557.

Deferred layers remain out of this PR: broad Hrana single-command retry and transaction recovery, ADO.NET schema/GUID/enum/isolation compatibility, the Turso.Data.Sqlite managed remote/replica backend, EF Core integration, NativeAOT/mobile/package-consumer work and CI, and Rust changes.

Validation

  • dotnet format bindings/dotnet/Turso.slnx --no-restore --include <changed C# files>
  • dotnet build bindings/dotnet/src/Turso.Data/Turso.Data.csproj --no-restore --configuration Debug (net8.0, net9.0, net10.0)
  • focused replica, direct-remote batch, transaction, and lifetime tests: 50 passed
  • full Turso.Tests: 207 passed, 1 skipped

Execute replica batch commands in order through the existing local connection and expose their buffered results through DbDataReader. Keep replica batches non-atomic unless callers attach an explicit transaction, and keep active batch readers inside the sync-operation lifetime gate.

Reset expired remote batch sessions without replaying a possibly partially applied batch. Invalidate an expired transaction stream rather than allowing later statements to escape its transaction.

Tests: dotnet build Turso.Data.csproj (net8.0, net9.0, net10.0); dotnet test Turso.Tests.csproj (207 passed, 1 skipped)
@awakecoding
awakecoding requested a review from penberg as a code owner August 31, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant