After SqlException application state is corrupted
See original GitHub issueEnvironment: OS - Windows Server 2012 R2 .NET Core: 2.0.5 SQL Server 2016
Exception:
System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The wait operation timed out.) ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at bool System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, uint waitForMultipleObjectsTimeout, bool allowCreate, bool onlyOneCheckConnection, DbConnectionOptions userOptions, out DbConnectionInternal connection)
at bool System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource<DbConnectionInternal> retry, DbConnectionOptions userOptions, out DbConnectionInternal connection)
at bool System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource<DbConnectionInternal> retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, out DbConnectionInternal connection)
at bool System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource<DbConnectionInternal> retry, DbConnectionOptions userOptions)
at bool System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource<DbConnectionInternal> retry)
at Task System.Data.SqlClient.SqlConnection.OpenAsync(CancellationToken cancellationToken)
at async Task<byte[]> Microsoft.Extensions.Caching.SqlServer.DatabaseOperations.GetCacheItemAsync(string key, bool includeValue, CancellationToken token)
at async Task Microsoft.Extensions.Caching.SqlServer.DatabaseOperations.RefreshCacheItemAsync(string key, CancellationToken token)
at async Task Microsoft.Extensions.Caching.SqlServer.SqlServerCache.RefreshAsync(string key, CancellationToken token)
at async Task Microsoft.AspNetCore.Session.DistributedSession.CommitAsync(CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
ClientConnectionId:f8356379-665e-484b-9093-e8e99ae10a72
Error Number:258,State:0,Class:20
This issue has come up in production in two separate occasions this week and once the ASP.NET Core app enters into this state only restarting the app resolves the problem. A few points I want to share:
1- It seems like something in the Connection Pool is getting corrupted once this happens. Since a restart fixes it.
2- The error seems related to some SSL issue based on the exception details (Provider SSL
). However, our connection strings do not specify the Encrypt
attribute.
3- There are a few issues reported with the same exception here, but in Linux/Mac environments. In this case this is an all Windows environment.
Issue Analytics
- State:
- Created 5 years ago
- Comments:24 (1 by maintainers)
Top Results From Across the Web
Why is my SqlConnection entering a broken state during ...
I have a simple console app that is executing a series of stored procedures about 150,000 times. It's purpose is to import initial...
Read more >Code analysis rule CA2153 for Corrupted State Exceptions ...
Corrupted State Exceptions (CSEs) indicate that memory corruption exists in your process. Catching these rather than allowing the process to ...
Read more >java.sql.SQLException: Log Corrupted, has invalid data in ...
SQLException : Log Corrupted, has invalid data in the log stream. ... We use Java Webstart to deploy the swing app to the...
Read more >java.sql.SQLException with SQL State XJ040 Error Code ...
Derby uses file system space to store the tables and the stored database was corrupted. One possible cause for this error is that...
Read more >The connection is broken and recovery is not possible - sql ...
I am having the following sql server error, while creating tempDB files. Any ideas? enter image description here. The connection is broken and ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
“The transaction isolation level issue with sp_reset_connection was fixed/changed in SQL Server 2014.”
It wasn’t. I reproduced it on SQL 2014 back when I used to run that.
The workaround needs to remain even if that particular issue is fixed because it’s still fixing the stale connection in pool problem.
@saurabh500 I emailed a link to the memory dump to you early today.