2

I've had an ongoing issue with the following exception when calling SubmitChanges() on a data context:

"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated."

This is happening on an ASP.NET web application that is being used by 5-100 concurrent users. Note that increasing the timeout period for the site/database has not helped and the queries being run are very simple and fast. I've gone so far as to remove the timeout period altogether which causes the site to hang indefinitely when the error occurs.

Other aspects of this problem:

  • It's intermittent and can't be reproduced reliably
  • It only occurs in a couple of different methods, never any others
  • Increasing or removing the timeout period does not help
  • Rebooting the server and restarting the MSSQL database hasn't helped

This seems like it might be a concurrency/deadlocking issue but I have no idea how to debug it or fix it. Any ideas?

Payton Staub
  • 487
  • 3
  • 10

1 Answers1

1

When the database operation is performed by the application and waiting for response of SubmitChanges try running the following query in Sqlserver

**sp_who2**

Have a look at Blkby column in the returned output. If you find one row with some value (This is SPID of the commands blocking your connection).

Check the ProgramName in that column to find some more info.

If you find the SPID that is blocking as described then run the following command to find the last query executed on that SPID. say Blkby has value of 59

**dbcc inputbuffer(59)**

This will give the query blocking your application query.

This is one way to troubleshoot.

Sometimes Timeout occurs due to default valued parameters in stored procedures causing parameter sniffing.

in that case you can try using the line as the first line in procedures used

SET ARITHABORT ON

Alter the procedure and try the database operation again.

If works you may remove this line afterwards and then alter procedure again.

Try this if it works for you.

I found a similar question here

Also read more information about query running slow in Web app and instantly in SSMS here

Stored procedure slow when called from web, fast from Management Studio

Hope it helps.

Community
  • 1
  • 1
Dinesh
  • 3,652
  • 2
  • 25
  • 35
  • Thanks Dnsh, I will give this a try and let you know if it works. Since the problem is intermittent I'll need to wait for some timeouts to start happening and then I'll check the Blkby – Payton Staub Jul 02 '12 at 13:07