Skip to content

Server transactions are stubs: Begin/Commit/Rollback accept the call but every statement autocommits #560

Done

Description

@MPCoreDeveloper

What happens

BeginTransaction, CommitTransaction and RollbackTransaction accept the call, hand out a transaction id and null it again — they never touch a database connection:

  • src/SharpCoreDB.Server.Core/DatabaseService.cs:592-616 — BeginTransaction only sets session.ActiveTransactionId = Guid.NewGuid().
  • DatabaseService.cs:631 — // Transaction commit logic would go here, then session.ActiveTransactionId = null.
  • DatabaseService.cs:656 — same for rollback.
  • ExecuteQuery (DatabaseService.cs:281) and ExecuteNonQuery (DatabaseService.cs:443) each take a fresh pooled connection (session.DatabaseInstance.GetConnectionAsync) and never read session.ActiveTransactionId, so every statement autocommits.
  • The client cannot enlist either: NonQueryRequest/QueryRequest carry session_id, sql, parameters, timeout_ms — no transaction id (src/SharpCoreDB.Client/SharpCoreDBCommand.cs:68-115).

Reproduction (published artifacts, 2026-12-04)

SharpCoreDB.Client 2.3.2 (nuget.org) against ghcr.io/mpcoredeveloper/sharpcoredb-server:2.3.2, dev TLS cert, gRPC :5001:

OPENED session=… version=2.3.2 token=issued
CREATE TABLE scdms_probe (id INTEGER PRIMARY KEY, note TEXT NOT NULL, score REAL)
INSERT id=1 …; INSERT id=2 …            -- 2 rows
begin → INSERT id=3 → COMMIT              → COUNT(*) = 3   (correct)
begin → INSERT id=4 → ROLLBACK            → COUNT(*) = 4   (row 4 survived the rollback)

So a client that "rolls back" keeps the writes. ExecuteBatch.transactional (proto field 3) is equally meaningless today.

Impact

Any client that offers transactions is lying, and any client that applies a multi-statement change "atomically" (staged grid editing, import, DDL + backfill) cannot recover from a failure halfway. SCDMS (MPCoreDeveloper/SCDMS) therefore keeps sql.transactions and server-side staged editing gated with exactly this reason in its capability contract; the local embedded engine/provider is unaffected (2.3.2 fixed the local commit defect from #546).

Expected

  • A session with an active transaction executes subsequent statements on that transaction's connection; Commit persists them, Rollback discards them (including after a later select/reopen).
  • Concurrent sessions must not see uncommitted rows.
  • Red→green tests in ConnectionLifecycleTests/a new TransactionEnlistmentTests, and a live check in the container harness.

Found while moving SCDMS to 2.3.2 (MPCoreDeveloper/SCDMS, commit c327c01); the same probe is reusable as a regression check.

Activity

  1. added
    bug
    area:server
    priority:p1
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:serverbugpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions