Skip to content
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

MultipleActiveResultSets=True (MARS) and query throws an exception when transaction is promoted #1920

Open
Dusan8080 opened this issue Feb 8, 2023 · 3 comments
Labels
🎨 By Design Issues due to driver feature design and will not be fixed.

Comments

@Dusan8080
Copy link

Describe the bug

Distributed transactions are turned on. Connection string has MultipleActiveResultSets=True.
It works with:

Microsoft.Data.SqlClient 2.1.2
System.Data.SqlClient.SqlInternalConnectionTds
ExecuteTransactionYukon

if (internalTransaction != null && internalTransaction.IsDelegated)
{
if (_parser.MARSOn)
{
tdsParserStateObject = _parser.GetSession(this);
flag = true;
}
else if (internalTransaction.OpenResultsCount != 0)
{
throw SQL.CannotCompleteDelegatedTransactionWithOpenResults(this);
}
}

It throws an exception with:
Microsoft.Data.SqlClient 2.1.3
Microsoft.Data.SqlClient.SqlInternalConnectionTds
ExecuteTransactionYukon

if (internalTransaction != null && internalTransaction.IsDelegated)
{
if (_parser.MARSOn)
{
stateObj = _parser.GetSession(this);
mustPutSession = true;
}
if (internalTransaction.OpenResultsCount != 0)
{
SqlClientEventSource.Log.TryTraceEvent("<sc.SqlInternalConnectionTds.ExecuteTransactionYukon|DATA|CATCH> {0}, Connection is marked to be doomed when closed. Transaction ended with OpenResultsCount {1} > 0, MARSOn {2}", base.ObjectID, internalTransaction.OpenResultsCount, _parser.MARSOn);
throw SQL.CannotCompleteDelegatedTransactionWithOpenResults(this, _parser.MARSOn);
}
}

Between versions 2.1.2 and 2.1.3 there is change from "else if" -> "if"

Did not find anything about breaking changes between versions in release notes. Any explanation?

@lcheunglci lcheunglci added the 🆕 Triage Needed For new issues, not triaged yet. label Feb 8, 2023
@lcheunglci
Copy link
Contributor

Thanks @Dusan8080 for bring this issue to our attention. We'll have a look at it soon.

@lcheunglci
Copy link
Contributor

lcheunglci commented Feb 15, 2023

Hi @Dusan8080 , from inspecting the changes, it appears the change was to resolve this issue #980 from this PR #1023. Also, is your project running .NET Framework or .NET Core? Also, what version of .NET Core were you using? The fix also aligned the code to match the behavior between .NET Core and .NET Framework.

@lcheunglci lcheunglci added 🎨 By Design Issues due to driver feature design and will not be fixed. and removed 🆕 Triage Needed For new issues, not triaged yet. labels Feb 15, 2023
@Dusan8080
Copy link
Author

Hi @lcheunglci, our project is running .NET Framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎨 By Design Issues due to driver feature design and will not be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants