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

MARS TDS header contained errors #687

Closed
meirib opened this issue Aug 13, 2020 · 9 comments
Closed

MARS TDS header contained errors #687

meirib opened this issue Aug 13, 2020 · 9 comments

Comments

@meirib
Copy link

meirib commented Aug 13, 2020

@ajcvickers

Following my previous post:
dotnet/aspnetcore#24831

This error occurs spontaneously on Azure MSSQL, and only a web app restart seems to help:

Microsoft.Data.SqlClient.SqlException (0x80131904): The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors.

Unfortunately, I'm using a 3rd party nuget that reproduces this issue, thus I cannot provide a runnable code for investigation.

However, It appears that this 3rd party uses Microsoft.EntityFrameworkCore.SqlServer (V3.1.6), which uses:
Microsoft.Data.SqlClient (V1.1.3) as it's default dependency version.

image

According this issue:
#85

I cannot conclude whether this issue is resolved in Microsoft.Data.SqlClient (V2.0.0) or not.
If so, an upgrade should resolve this matter?

@karinazhou
Copy link
Member

karinazhou commented Aug 13, 2020

Hi @meirib ,

We have fixed this issue in Microsoft.Data.SqlClient v2.0.0 in this PR #547 . This fix is ported back to v1.1.3 #550 .

Do you know whether the application calls the SqlDataReader or SqlBulkCopy? It may be related to some known issues we have. And if possible, an application with Microsoft.Data.SqlClient driver only will help to narrow down the investigation.

@meirib
Copy link
Author

meirib commented Aug 17, 2020

@karinazhou ,

Seems like upgrading to Microsoft.Data.SqlClient v2.0.0 solved the issue.
According to the 3rd party we use, well, they use "EF abstraction layer -- not SqlClient directly"

@karinazhou
Copy link
Member

@meirib Since we have the same fix both in version 2.0.0 and version 1.1.3, the EntityFrameworkCore.SqlServer (V3.1.6) should also work in your scenario.

Seems like upgrading to Microsoft.Data.SqlClient v2.0.0 solved the issue.

Do you have the repo app to confirm this?

@meirib
Copy link
Author

meirib commented Aug 19, 2020

@karinazhou
Well, it's not working - MARS error is produced spontaneously in V1.1.3.
Only by manually upgrading to V2.0.0 we were able to overcome this, annoying infrastructure crisis, which caused us a sever malfunctioning unexpected system behavior.

For what it's worth, these are the properties:

image

image

Whereas this constellation seems to be working:

image

@karinazhou
Copy link
Member

@meirib I can see that you are posting the properties of System.Data.SqlClient.dll. Is this posted by mistake?
The Microsoft.Data.SqlClient.dll should be the one that your application loads.

And for this working case:

Whereas this constellation seems to be working:

It looks like you not only upgrade the Microsoft.Data.SqlClient but also upgrade the EFCore version. Could you try one more thing?

  1. Keep Microsoft.Data.SqlClient reference as v2.0.0
  2. Keep Microsoft.EntityFrameworkCore.SqlServer reference as v3.1.6

Does this issue still happen with this combination?

@meirib
Copy link
Author

meirib commented Aug 23, 2020

@karinazhou Sorry, my mistake.

This is the correct one:

image

If I recall, the Microsoft.EntityFrameworkCore.SqlServer v3.1.6 & Microsoft.Data.SqlClient v2.0.0 combination works.

@karinazhou
Copy link
Member

karinazhou commented Aug 25, 2020

@meirib Thank you for confirming it. From the library property you posted, it is from the \lib folder other than the actual working one from \runtimes folder. Is this the one loaded by your application when using EFCore v3.1.6 only?

image

From all the clues we have now, we know that direct reference to the Microsoft.Data.SqlClient v2.0.0 works fine no matter what version of EFCore your application uses. And use EFCore v3.1.6 only fails the application.

  • MDS v2.0.0 + EFCore v3.1.7 --> succeed
  • MDS v2.0.0 + EFCore v3.1.6 --> succeed
  • EFCore v3.1.6 --> fail
  • MDS v1.1.3 + EFCore v3.1.6 --> ?
  • EFCore v3.1.7 --> ?

Can you also try the last two combinations to validate the behavior?


I have some updates from local testing. When I add Microsoft.EntityFrameworkCore.SqlServer v3.1.6 to my simple .net core console application, I find that it depends on the Microsoft.Data.SqlClient v1.0.19269.1 instead of v1.1.3:

image

That version of the driver doesn't contain the TDS header fix which will cause the exception you have seen. If you only have reference to EFCore v3.1.6, it will use that MDS version by default. According to nuget.org, EFCore.SqlServer v3.1.7 will grab the MDS v1.1.3.

https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/3.1.7

From your testing results, it looks like the application will use the right MDS version when you explicitly specify it in your project. To verify it, you can set breakpoints in your program to see which Microfost.Data.SqlClient.dll is loaded by your application.

@karinazhou
Copy link
Member

Hi @meirib ,
Any updates on this?

@cheenamalhotra
Copy link
Member

Closing as duplicate of #85
Please follow us there if you have more questions on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants