-
Notifications
You must be signed in to change notification settings - Fork 286
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
The MARS TDS header contained errors using ASP.NET Core and EF Core connecting to Azure SQL Server #85
Comments
Regarding the stackoverflow issue addiotional questions asked by Afsaneh: Unfortunately can't post the csproj file contents...
|
Here's the Dump of the SqlError object: Class: Errors: Error code: Line number: Number: SQL Procedure: Source: State: |
I had a random spate of these errors appear in my ASP.NET application today. I use ASP.NET Core 2.1, EF Core 2.1 and Azure SQL Database. They occurred in a small time window and once I stopped and started the web app the errors seemed to stop. I think I queried successfully from SSMS while the errors were happening but couldn't say for sure that it was at the same time. If it happens again I'll query in SSMS to confirm that I can. Is there anything I can provide that will help with a solution to this? (I have application insights and database logging turned on for my application) NOTES: |
@afsanehr I wouldn't even know where to start, I've so far only seen it once today and restarting my application made it stop happening. I will keep my eyes open and if it starts happening in a pattern of some kind I'll try and put one together but at the moment it seems random so I've got no starting point for a repro. I realise that's useless to you as well though haha I have got about 130x exceptions logged in my App Insights at the moment but I doubt the stack trace would be enough for you? It also looks like the error occurred on ALL queries no matter where they originated from so it doesn't appear to be a query specific issue. |
I confirm the same - errors occurring at random queries, random time. I've tried to stress-test the application by running 30 threads that was making DB queries in parallel, but that didn't reproduce the issue either. I've tried to use the SSMS query while the error was occurring and it worked, I've also tried to deploy to another azure release slot at the time the issue was occurring and it worked. What I've temporarily ended up with was writing a middleware that once detects this particular error [based on the err message], automatically restarts the web app. As the issue occurs 1-2 times a day, it's acceptable, but much better would be having the issue solved. What connects both mine and Adam's issue is the ASP.NET Core 2.1 + EF Core 2.1 + Azure SQL DB combo, but I cannot even say what part of the chain to blame. |
Here you go, obtained from the Azure console .NET Core SDK (reflecting any global.json): Runtime Environment: Host (useful for support): .NET Core SDKs installed: .NET Core runtimes installed: To install additional .NET Core runtimes or SDKs: |
Here's mine 👍 .NET Core SDK (reflecting any global.json): Runtime Environment: Host (useful for support): .NET Core SDKs installed: .NET Core runtimes installed: To install additional .NET Core runtimes or SDKs: |
Hello, we have experiensed same problem: System.Data.SqlClient.SqlException (0x80131904): The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors. We use
How to reproduce: When we increased log file, .net 4.7 apps starts to work, but .net core app continue to throw exception. Only restart of application helped |
I got this again this morning between 07:38:09 and 07:39:22. Not sure if that's useful to help you track anything down or not. (I did nothing to any of my services to stop it happening but I then have successful requests being processed at 07:40:06) |
I managed to temporarily auto-mitigate the issue by creating custom Entity framework execution strategy that once encounters the MARS error, closes the connection, clears the pool and reopens. Since I've introduced this workaround, I've been running errorless for 3 days. To sum it up. Once the error is encountered, closing & reopening the error connection + clearing the connection pool seems to re-establish working order |
We are getting the same problem. Application Server Database Application |
We're having the same issue. Any solutions? |
@afsanehr |
@PolitovArtyom Yes. That would be helpful. |
MARS is not enabled on client and disabled on server |
We're also having the same issue. With NetCore, EFCore and an Azure SQL db |
@brunolau could you maybe create a gist with the workaround. |
Sure, I will post it in a couple of days, I'm away from the PC for a couple of days and as soon as I get back, I'll do it |
Just 1 more thing. I've been facing this error for a few days now. I have a durable function which calls my Sql Server VM. The version of Sql Server configured was Sql Server 2017 On a hunch I fired up a new VM, this time with Sql Server 2016. And so far my durable function seems to be working fine. I really throttled it because I was worried maybe the number of connections was causing the problem. So the function is running very slowly now but still it has no errors, so far. |
@mshenoy83 Sorry it took a bit longer, here goes my dirty hack. In order to use it, please check the "Custom execution strategy" section of this documentation https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency class CustomExecutionStrategy:
class SqlRecoveryAttemptor
|
+1 Am experiencing the same problem, not sure how to fix it besides repeatedly restarting (based on comments above). |
Same issue here since migrating to EF Core from EF6 in Dec 2018. We see this happen randomly on a single server (among many that are hitting the DB). We have gone 10-15 days without seeing it, then it just pops up and doesn't recover until the server is restarted. Currently using EF Core 2.2.3 on Azure SQL DB |
I second to that - for us it started once we migrated from ASP.NET to ASP.NET Core |
Just to chime in, I just experienced this issue in Azure Functions v2 (.Net Core 2.1). I am using EFCore v2.2.3 to connect to Azure SQL. The call I am making to the DB that was spawning the error was as basic as it gets, essentially a SELECT * into a table with 2 rows and 8 columns. Since my deployment is a little different from the above, maybe this will help:
Up until recently, this app lived on a Sql Server Web Deployment on a Ubuntu VM. I had never seen this particular error (but had another odd SSL error instead that exhibited similar behavior, with restart fixing). I will also say that at that time I was using EF Core 2.1.4 as well, and only recently upgraded to 2.2.3. Connection string is the same for all 3 deployments, the MARS section is: MultipleActiveResultSets=False; It appears to have started during a period of high DTU use (about 40 min at 90%+). This is not an infrequent occurrence, however, and has actually happened far less over the past day. Hopefully that helps. |
As recently announced in the .NET Blog, focus on new SqlClient features an improvements is moving to the new Microsoft.Data.SqlClient package. For this reason, we are moving this issue to the new repo at https://github.com/dotnet/SqlClient. We will still use https://github.com/dotnet/corefx to track issues on other providers like System.Data.Odbc and System.Data.OleDB, and general ADO.NET and .NET data access issues. |
We have same problem for the following run time env, currently solved the problem solution provided by @brunolau Application Server Application |
What happens to the underlying original request (say for example, it was a SELECT statement)? |
As far as I'm not mistaken the execution strategy should ensure that the request is retried after the cleanup is done so no harm happening other than pool cleanup afaik |
Hi, |
Hi @DVAD7427 Did you try setting AppContext switch as mentioned here: #85 (comment) |
Closing as issue has been fixed and backported to all versions. |
This issue started occurring for us on 8/12, which is well after these fixes have been backported to previous versions. It started occurring in a current release, that wasnt previously having the issue. The company did VMWare upgrades it appears, could this be something that is causing this? |
I'm getting this error too. I've submitted an issue here: |
This repository only provides update to Microsoft.Data.SqlClient, however System.Data.SqlClient was updated with this fix too for v4.8.2. Please use v4.8.2+ to get this fix. |
Just saw this in the wild running .net 4.8/SQL 2019/Server 2019 using system.data.sqlclient\4.8.5\runtimes\win\lib\netstandard2.0\System.Data.SqlClient.dll which is supposed to be fixed for this. Just recently installed KB5023702 and Servicing Stack 10.0.17763.4121 We are actually in the process of moving to microsoft.data.sqlclient/latest for all code. Assuming this is an entirely separate issue? Recycling the impacted application pool was the only way we were able to recover and assume at least for now mitigation would be ensure when we catch this to clear the pool for that connection? No reproduction code yet. System.Data.SqlClient.SqlException (0x80131904): The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors. Failing on both execute reader as well as opening connetions. |
I think I missed the part where we need to also add MakeReadAsyncBlocking = true for .net framework clients. Can you guys confirm this bug is still possible with System.Data.SqlClient if we did not set that? Probably moot point since we are about to shift to Microsoft.Data.SqlClient. |
did any one fixed the issue ? |
|
I am currently using System.Data.SqlClient version 4.8.5 and facing the same issue. |
Still have the same issue with System.Data.SqlClient version 4.8.6 |
System.Data.SqlClient is currently in servicing mode and only receives security updates. To ensure you benefit from the latest updates and features, I highly recommend transitioning to Microsoft.Data.SqlClient. |
This appeared as a new issue after patching System.Data.SqlClient to version 4.8.6. Must be some regression issue after the latest security fixes? |
The real fix seems to be adding to your SQL connection string: I have no idea what it does, but whatever it is, it can't be worse than currently having random SQL connection failures in production. |
It seems even "MultipleActiveResultSets=False" is not fixing this totally reliably. |
@Thorium This issue is closed. I you encounter issues, I suggest create a new github issue with a runnable repro. |
Copied from here:
I have an ASP.NET Core app [Microsoft.AspNetCore.App 2.1.4] with EF Core 2.1.4 [DbContext pooling enabled] and data stored on an Azure SQL database.
Occasionally [once in 1-2 days] I get unrecoverable error stating System.Data.SqlClient.SqlException (0x80131904): The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors.
Once I restart the app, everything resumes working until it happens again.
Probably import to note is that I don't have MultipleActiveResultSets enabled in my connection string at all, which makes the issue even more strange.
Has anyone else noticed something similar? Are there any ways I can trace the problem?
Stack trace:
The text was updated successfully, but these errors were encountered: