If exists, update is getting timeout from using ExecuteNonQueryAsync() in C# Azure Function from about 450k rows in SQL Server


I am getting a timeout error from using ExecuteNonQueryAsync() to do an update if something exists. The table that I am doing the update has about 450k rows so I wonder if this has something to do with it.

Below is the query

IF EXISTS (SELECT * FROM dbo.File_Tracker WHERE file_name = @filename)
    UPDATE dbo.File_Tracker SET
        file_purge_indicator = 'Y'
        , file_purged_time = @file_received_time
        , file_purgedby = @file_purgedby_duplicate
    WHERE file_name = @filename and file_purge_indicator = 'N'

The following is the error that I am getting. I would like to know why this is happening and how to fix it.

System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): 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.SqlCommand.InternalEndExecuteNonQuery(IAsyncResult asyncResult, String endMethod, Boolean isInternal)
   at System.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(IAsyncResult asyncResult)
   at System.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
asked on Stack Overflow Jan 22, 2020 by Ace Sok • edited Jan 22, 2020 by Dale K

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0