-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve distributed transactions on pooled connection reset #3019
base: main
Are you sure you want to change the base?
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3019 +/- ##
==========================================
+ Coverage 72.68% 72.70% +0.01%
==========================================
Files 283 283
Lines 58975 58976 +1
==========================================
+ Hits 42864 42876 +12
+ Misses 16111 16100 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
...t.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
@@ -1075,9 +1075,11 @@ private void ResetConnection() | |||
// distributed transaction - otherwise don't reset! | |||
if (Is2000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving Is2000 logic in place for now until we remove support for it. The fix will not apply to versions before 2000.
|
||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), Timeout = 10000)] | ||
|
||
public void Test_EnlistedTransactionPreservedWhilePooled() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified that these tests currently fail when run on main against an azure db.
The current behavior only preserves transaction state for the root transaction. Enlisted connections that are reset will be placed in the transacted connection pool, but in some situations, will no longer participate in the transaction. The next connection to request the connection will expect it to be participating in the transaction, but actions on the connection will auto-commit.
This changes the reset logic to preserve transaction state for enlisted connections (part of a distributed transaction, but not root).