This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
[Release 3.1] Avoid enlistment of pooled connection in aborted transaction #42937
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ports dotnet/SqlClient#551 and dotnet/SqlClient#543 to System.Data.SqlClient.
Summary
Fixes issue dotnet/SqlClient#237 that occurs due to driver enlisting pooled connection in stale transaction which is due abort from SysTx.Transactions on the server. This incorrect enlistment causes server to perform forth-coming operations in implicit mode, causing unwanted commits.
The fix ensures if a transaction gets aborted externally, the corresponding connection is not sent back to the pool.
Customer Impact
High This bug causes the driver to perform commits outside transaction even though client is presumably working inside a transaction. It qualifies for a security issue.
Regression?
No, this issue is reproducible with all SqlClient drivers.
Testing
This issue has not yet been reproduced in .NET Core applications but the driver behavior being same to that of .NET Framework needs to be fixed. The issue happens intermittently and is more likely to happen on SQL Server machines working in heavy load. The original issue was reproduced in WPF Client application, with failures seen intermittently. But client applications on any platform are susceptible to this issue.
Risk
Low: The fix has been verified by customers with failing use-cases, and by our teams by validating driver behavior on how it works with aborted transactions.
The scope of changes is low, and the fix has also been released in Microsoft.Data.SqlClient v1.1.1 and v2.0.0.
cc: @danmosemsft @saurabh500 @David-Engel