Quantcast
Channel: Microsoft Drivers for PHP for SQL Server forum
Viewing all articles
Browse latest Browse all 163

Stored procedure timing out - was working fine.

$
0
0

I have a stored procedure which all of a sudden started to time out when called from the data access method for no apparent reason.  Here's the situation:

Its been running fine since its creation about 2 months ago.

It always returns the same fixed number of rows (about 6k rows), the only thing that changes are some of the values in those rows.

Its just a large sql statement, no cursors or anything out of the ordinary.

This has happened twice.  each time it was running find until I ran an update statement to change some of the values. in this case I set a bit column from 0 to 1, and set a date value in a datetime column to all 6k rows. the next time the application executed it, it started to time out.

it runs fine from SSMS where I execute it from the query window.  from here it executes instantly as expected.

the app code that executes the sproc where its timing out is:

qlConnection conn = null;
conn = DBConnectoinHelper.GetDBConnection();
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "dbo.spIssue_LTE_lst ";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add("@Df_Prj_Id", SqlDbType.UniqueIdentifier).Direction = ParameterDirection.Input;
cmd.Parameters["@Df_Prj_Id"].Value = id;
SqlDataReader rdr = cmd.ExecuteReader();

Here's the exception I get in this method when running the code above:

Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. "at System.Data.SqlClient.SqlConnection.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.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
   at DataServices.Issue_LTE_DataServices.Issue_LTE_GetListByFK(Guid id)"

The first time this happened, I deleted the sproc and then recreated it, then it ran OK again.  any idea what's happening here and how to trouble shoot/resolve it?

Thank you.


Viewing all articles
Browse latest Browse all 163

Trending Articles