2015-05-09 43 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. 在查詢中使用過濾器條件一次更新較小的一組數據。

相關問題