aspire
aspire copied to clipboard
SQL Timeouts with proxied connections
I've been facing a number of sparodic SQL timeouts - performance generally seems fine, but a number of timeouts show up in the logs. On a hunch, I tried disabling proxying of the sql endpoint and since then I haven't seen a timeout again.
//Try to mitigate timeouts
var endpoint= sql.Resource.Annotations.OfType<EndpointAnnotation>()
.Single(x => x.Name == sql.Resource.PrimaryEndpoint.EndpointName);
endpoint.IsProxied = false;
Any thoughts on what could be causing the timeouts, or how to trace down the issue.
We are currently using System.SqlClient
. We do have a branch in flight that's upgrading to Microsoft.SqlClient
, but tha'ts not quite ready to test with yet. We're seeing this in a couple of apps - both of which are windows exes talking to SQL running in a container.
I haven't caught any of these timeouts myself - I find them mainly in the logs from background tasks - I wonder if there is some kind of connection idle / time out that's not being fully handled.
Exceptions are all of the following form:
System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
---> System.ComponentModel.Win32Exception (258): The wait operation timed out.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at MYAPP.FOO.BAR ...