-
Notifications
You must be signed in to change notification settings - Fork 323
Pooled connection corrupted after TransactionScope rollback with failed DTC promotion #4001
Copy link
Copy link
Open
Labels
Repro Available ✔️Issues that are reproducible with repro provided.Issues that are reproducible with repro provided.
Description
Describe the bug
When a TransactionScope containing two enlisted connections rolls back (due to failed DTC promotion on .NET 8+ where ImplicitDistributedTransactions is disabled by default), the first connection is returned to the pool in a corrupted state. The pool does not discard it — subsequent Open() succeeds (State == Open), but BeginTransaction() throws:
Exception message:
System.InvalidOperationException: The requested operation cannot be completed because the connection has been broken.
Stack trace:
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
at Microsoft.Data.SqlClient.SqlInternalConnection.BeginSqlTransaction(IsolationLevel iso, String transactionName, Boolean shouldReconnect)
at Microsoft.Data.SqlClient.SqlConnection.BeginTransaction(IsolationLevel iso, String transactionName)
at Microsoft.Data.SqlClient.SqlConnection.BeginTransaction(IsolationLevel iso)
at Microsoft.Data.SqlClient.SqlConnection.BeginDbTransaction(IsolationLevel isolationLevel)
Pooling=false eliminates problem.
To reproduce
Se attached console application that reproduces issue
Expected behavior
Corrupted connections should be discarded by the pool, not returned on next Open().
Further technical details
Microsoft.Data.SqlClient version: 6.1.4
.NET target: .NET 10.0
Related: #2285 — same exception on pooled connections with TransactionScope, no repro available.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Repro Available ✔️Issues that are reproducible with repro provided.Issues that are reproducible with repro provided.
Type
Projects
Status
Investigating