I am encountering a problem with the CommandTimeout property of my SqlCommand that I'm using to execute a stored procedure.
using (SqlCommand command = new SqlCommand("_UpdateWorldeaseIDs", SqlC_SSuite))
{
command.CommandType = CommandType.StoredProcedure;
command.CommandTimeout = 600;
int rowsAffected = command.ExecuteNonQuery();
logger.log($": Rows affected = {rowsAffected}.", Log4NetExtension.Level.Info);
}
The code is fairly simple. The code used to not specify a CommandTimeout, so it would use the default of 30 seconds. It appears that this procedure can (not always) take longer than 30 seconds, so we raised it significantly to 600 seconds, presuming there was no way that wouldn't be long enough.
Strangely this morning we got another failure email that comes through automatically that said
"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."
I checked our log to see how much time elapsed between "Procedure begin" and "Procedure failed" logs, and it is basically 30 seconds. The image below shows that about 30 seconds after the command execution started, it failed.
What is happening here? I did try to read through most similar SO questions and MSDN forums, but to no avail so far.