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
Program.zip
Related: #2285 — same exception on pooled connections with TransactionScope, no repro available.
Describe the bug
When a
TransactionScopecontaining two enlisted connections rolls back (due to failed DTC promotion on .NET 8+ whereImplicitDistributedTransactionsis disabled by default), the first connection is returned to the pool in a corrupted state. The pool does not discard it — subsequentOpen()succeeds (State == Open), butBeginTransaction()throws:Pooling=falseeliminates 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
Program.zip
Related: #2285 — same exception on pooled connections with
TransactionScope, no repro available.