3

I have a query that, when executed from my application throws

[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.]

I get the same error when stepping through the code in Visual Studio.

But when executing the code in SQL Server Management studio using the same credentials, the query returns instantly (no rows are returned in this case).

The query is generated by Entity framework- I tested in SSMS by extracting the sql from the IQueryable and pasting it in a query window. The timeout error occurs when the code hits "ToList()".

The SQL Server is running in an Azure hosted VM.

For some context, I have seen similar behavior once before, but the last instance was a troublesome (and quite complex) stored procedure. Occasionally, the sp would get in a state where it would only time out from VS or .NET, but would run fine from SSMS. The fix would be to drop and re-create the SP.

This current query is simple by comparison, but I don't know how to "clear it" like I did with the sp, since it's generated on the client.

Does anyone know what could cause a particular query to time out, but only from some clients?

.NET 4.5., EF 6.0.

The query times out after 30 seconds (the default timeout period). I didn't think the actual contents of the query were relevant- the code that runs it has been in place for nearly a year, and has run without a problem until yesterday. It's a relatively simple query that joins 2 tables and has an EXISTS in the where clause on a third.

esmoore68
  • 1,276
  • 1
  • 8
  • 16
  • Make sure there is no circular reference – Faisal Jan 19 '16 at 15:08
  • network latency can affect this. You might consider setting your timeouts a little bit higher in code, particularly to account for clients with rather slow connections. – user2366842 Jan 19 '16 at 15:09
  • Without any code or details it's impossible to help. *How* long does the query execute? *What* version of .NET/EF are you using? Is the query taking so long that it really does time out and you have to increase the timeout? Or are you using an older version of .NET (before 4.5.2) that is sensitive to connectivity issues? – Panagiotis Kanavos Jan 19 '16 at 15:12
  • PS: Dropping and recreating the stored procedure is pointless. It simply means that any transient connectivity issues went away while you were executing statements – Panagiotis Kanavos Jan 19 '16 at 15:13
  • Question revised to add details. Can you explain or link to "sensitive to connectivity issues"? re: dropping and recreating- from all that I know about SQL server, you're correct. But the fact remains that this course of action would consistently ficx the problem with too high a – esmoore68 Jan 19 '16 at 16:19
  • 1
    maybe this can be of some help http://dba.stackexchange.com/a/9843/10825 – jbl Jan 19 '16 at 16:34

0 Answers0