Reputation: 820
Working with Entity framework and had a couple of questions on timeouts.
This following article http://blogs.msdn.com/b/khen1234/archive/2005/10/20/483015.aspx says
A client signals a query timeout to the server using an attention event. An attention
event is simply a distinct type of TDS packet a SQL Server client can send to it.
So SQL Server by itself (without a governor) cannot respect the issued command's timeout and kill it after the timeout expires.Take as an example the following query
var x = objectContext.Employees.Select(e => e.FirstName);
We issue the query - If we assume the query takes 40 seconds to complete and the default command timeout is 30 seconds. When is the attention event triggered?
A) At 30 seconds?
B) After 40 seconds (when the query returns after 40 seconds EF checks if it is greater than default and then throws the exception)?
Here I am also assuming the code also will throw a SqlException and automatically trigger an attention event.
Upvotes: 0
Views: 311
Reputation: 51494
At 30 seconds. Think of the Timeout amount as "Wait no longer than..."
The timeout will trigger a SqlException
. The "attention event" is lower level than that.
The client (EF, or whatever) keeps track of the query, and after the timeout, informs the server that it is no longer interested in the results, and throws an exception. Your client code should handle that exception appropriately.
Upvotes: 1