{"record":{"id":"eeec901e151d3db2","repo":"tursodatabase/turso","slug":"no-remote-transaction-is-active-on-this-connection","errorCode":null,"errorMessage":"No remote transaction is active on this connection.","messagePattern":"No remote transaction is active on this connection\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoConnection.cs","lineNumber":262,"sourceCode":"                .GetResult();\n        }\n        catch (TursoRemoteSqlException)\n        {\n            _remoteTransactionActive = false;\n            throw;\n        }\n        catch\n        {\n            InvalidateRemoteSession();\n            throw;\n        }\n    }\n\n    internal void CommitRemoteTransaction()\n    {\n        var remoteClient = _remoteClient ?? throw new InvalidOperationException(\"Turso database is closed.\");\n        if (!_remoteTransactionActive)\n            throw new InvalidOperationException(\"No remote transaction is active on this connection.\");\n\n        try\n        {\n            remoteClient\n                .ExecuteAsync(\"COMMIT\", new TursoParameterCollection(), wantRows: false, DefaultTimeout, closeAfter: false, CancellationToken.None)\n                .GetAwaiter()\n                .GetResult();\n        }\n        catch (TursoRemoteSqlException)\n        {\n            throw;\n        }\n        catch\n        {\n            InvalidateRemoteSession();\n            throw;\n        }\n","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Data/TursoConnection.cs#L244-L280","documentation":"CommitRemoteTransaction refuses to send COMMIT when _remoteTransactionActive is false: 'No remote transaction is active on this connection.' The flag is cleared by successful Commit/Rollback, by Close, and by session invalidation, so this error means the connection-level transaction already ended (or never began) while commit was still requested.","triggerScenarios":"Calling commit paths twice at the connection level; committing after the transaction was already rolled back or invalidated by an error; transaction bookkeeping desync after mixing manual BEGIN/COMMIT SQL statements with TursoTransaction on a remote connection; committing after Dispose-on-closed-connection completed the transaction out-of-band.","commonSituations":"Retry loops that re-commit the same unit of work; finally blocks that commit 'for safety' after an explicit rollback; wrappers that hold a TursoTransaction past its real end and commit again in a callback.","solutions":["Commit exactly once per transaction; after Commit or Rollback (or an error path that invalidated the session) treat the transaction as finished","In finally blocks, commit only if your own flag says the work succeeded and the transaction has not completed","Do not interleave raw BEGIN/COMMIT SQL with TursoTransaction on the same remote connection","Catch InvalidOperationException at the boundary and re-verify database state before assuming the commit landed"],"exampleFix":"// before\nvar committed = false;\ntry { /* work */ committed = true; }\nfinally { tx.Commit(); } // throws if tx already ended or never began\n\n// after\nvar committed = false;\ntry { /* work */ committed = true; }\nfinally { if (committed && !tx.IsCompleted) tx.Commit(); }","handlingStrategy":"validation","validationCode":"var ok = false;\ntry { /* work */ tx.Commit(); ok = true; }\nfinally { if (!ok && !tx.IsCompleted) tx.Rollback(); }","typeGuard":"static bool IsUsableTransaction(TursoTransaction tx) => !tx.IsCompleted;","tryCatchPattern":"try { tx.Commit(); }\ncatch (InvalidOperationException ex) when (ex.Message == \"No remote transaction is active on this connection.\")\n{\n    // transaction already ended; verify database state if the outcome matters\n}","preventionTips":["Commit exactly once; treat the transaction as spent afterward","Guard cleanup commits with a success flag plus completion state","Do not mix manual BEGIN/COMMIT SQL with TursoTransaction on remote connections"],"tags":["csharp","dotnet","turso","transactions","remote"],"backgroundTag":"invalid-transaction-state","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}