-
Notifications
You must be signed in to change notification settings - Fork 314
Description
Describe the bug
Starting with 2.1.3, we experienced deadlocking issues when a TransactionScope is disposed. Either the code should fully commit, or it should throw a TransactionAbortedException
or some such, but instead it just hangs on the end of the using
block where the TransactionScope
is disposed.
May be an unintended consequence of #1049, the deadlock does not occur in 2.1.2 but does occur in 2.1.3 and 3.0.0.
At Particular Software we have a test for our SQL Transport designed to ensure that certain things happen when a transaction is aborted that was deadlocking every single time. We were able to slim this down into a minimal repro.
We have another situation where we were spinning up two connections to the same server to test the database's support for DTC. This was also hanging but it appeared like a race condition. The repro below happens consistently.
To reproduce
The code in this gist is a minimal reproduction of the problem.
- Run pointed at a local SQL Express instance, or change the connection string to match.
- As written (using v2.1.3) it will hang and never complete.
- Changing to v2.1.2 (and being sure to rebuild) will result in an a
TransactionAbortedException
being quickly thrown, caught, and printed to the console, after which the program will complete.
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
Expected behavior
Should throw TransactionAbortedException
instead of hanging.
Further technical details
- Microsoft.Data.SqlClient version: 2.1.3 or 3.0.0
- .NET target: .NET Framework 4.7.2
- SQL Server version: Microsoft SQL Server 2019 (RTM-GDR) (KB4583458) - 15.0.2080.9 (X64) Nov 6 2020 16:50:01 Copyright (C) 2019 Microsoft Corporation Express Edition (64-bit) on Windows 10 Home 10.0 (Build 19042: ) (Hypervisor)
- Operating system: Windows 10 Home (10.0.19042 Build 19042)