Sql server 实体框架在保存更改时出现间歇性超时
我们在使用Entity Framework调用Sql server 实体框架在保存更改时出现间歇性超时,sql-server,entity-framework,Sql Server,Entity Framework,我们在使用Entity Framework调用SaveChanges时遇到间歇性超时,我决定打开数据库.LogonDbContext尝试了解发生了什么,输出如下: Opened connection at 5/9/2015 4:56:57 PM +00:00 Started transaction at 5/9/2015 4:56:57 PM +00:00 UPDATE [Search].[IndexingStatuses] SET [DateTimeLastUpdated] = @0, [
SaveChanges
时遇到间歇性超时,我决定打开数据库.Log
onDbContext
尝试了解发生了什么,输出如下:
Opened connection at 5/9/2015 4:56:57 PM +00:00
Started transaction at 5/9/2015 4:56:57 PM +00:00
UPDATE [Search].[IndexingStatuses]
SET [DateTimeLastUpdated] = @0, [IndexStores_IndexStoreId] = @1
WHERE ([CustomerId] = @2)
-- @0: '5/9/2015 4:03:57 PM' (Type = DateTime2)
-- @1: '2' (Type = Int16)
-- @2: '1' (Type = Int32)
-- Executing at 5/9/2015 4:56:57 PM +00:00
-- Completed in 1 ms with result: 1
Failed to commit transaction at 5/9/2015 4:57:13 PM +00:00 with error: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Closed connection at 5/9/2015 4:57:13 PM +00:00
这是非常奇怪的,这是一个简单的更新,正如您所看到的,事务在4:56:57开始,更新需要1毫秒,但由于某种原因,在4:57:13有一个超时,只晚了16秒,这比我们的超时限制要小
有人知道为什么我们会间歇性地收到这些信息吗?我不能肯定,但您的服务器似乎使用的可用内存非常少。以下事项之一可能适用于您-
您正在使用TransactionScope吗?没有事务Scope。需要查看代码才能知道发生了什么。