2015-05-09 56 views
3

我们一直在呼吁SaveChanges实体框架得到间歇性的超时,我决定打开Database.LogDbContext,试图找出发生了什么事情,输出率为:实体框架间歇超时在调用SaveChanges

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 ms,但由于某种原因,在4:57:13有一个超时只有16秒后,这比我们的超时限制还要少。

有谁知道我们为什么间歇性地得到这些?

+0

您是否正在使用TransactionScope? – ESG

+0

没有交易范围 – user351711

+0

嗯。需要看代码才能知道发生了什么。 – ESG

回答

0

我不能说肯定,但它似乎你的服务器运行在一个非常少的可用内存。以下其中一种情况可能适用于您 -

  1. Incresing Timeout for a large value once。可能查询不会花费很多时间,因为它已经有了执行计划。
  2. 删除事务日志,tempDb数据。

  3. 在查询中使用过滤器条件一次更新较小的一组数据。

相关问题