2

我已經託管我的網站rackspace雲服務器。有時得到超時過期異常與Linq EF和服務器重新啓動後,它工作正常

有時我從數據庫中獲取記錄時遇到以下異常。奇怪的是,重啓後幾天內一切正常,我也只在少數幾個地方得到這個異常,而不是在任何地方。

Exception: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 

Stack Trace: 


[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.] 
    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +404 
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412 
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1363 
    System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +59 
    System.Data.SqlClient.SqlDataReader.get_MetaData() +118 
    System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +6387937 
    System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +6389506 
    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +538 
    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +28 
    System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +256 
    System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +19 
    System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) +553 

[EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details.] 
    DataAccessLayer.dbCustomer.CompanyCustomerByLocationId(String sortExpression, Boolean asc, String nameSearchString, Int32 startRowIndex, Int32 maximumRows, Int32& TotalRecord, Int64 companyId) in D:\Dotnet Projects\FutureZoom\FutureZoom\DataAccessLayer\dbCustomer.cs:508 
    BusinessLogic.Customer.CompanyCustomerByLocationId(String sortExpression, Boolean asc, String nameSearchString, Int32 startRowIndex, Int32 maximumRows, Int64 CompanyId) in D:\Dotnet Projects\FutureZoom\FutureZoom\BusinessLogic\Customer.cs:431 
    FutureZoom.Areas.Admin.Controllers.CompanyController.CustomerPaging(Int32 StartIndex, Int32 PageSize, String SortExp, Boolean Asc, String SearchExp, String Where) in D:\Dotnet Projects\FutureZoom\FutureZoom\FutureZoom\Areas\Admin\Controllers\CompanyController.cs:552 
    lambda_method(Closure , ControllerBase , Object[]) +362 
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +248 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39 
    System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +125 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +640 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +312 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +691 
    System.Web.Mvc.Controller.ExecuteCore() +162 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +305 
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62 
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375 

我的LINQ查詢下面

query = context.Customers.Include("Company").Include("Company.EmailCampaignerStatus") 
              .OrderBy(m => m.EmailCampaignerStatus.FirstOrDefault().CreatedOn)           
              .Where(m => m.FirstName.StartsWith(name) || m.LastName.StartsWith(name) || m.Email.StartsWith(name) || (m.FirstName + " " + m.LastName).StartsWith(name)) 
              .Where(m => m.CompanyId == companyId) 
              .Where(m => m.CompanyLocationId == locationId) 
              .Skip(startRowIndex == 0 ? startRowIndex : startRowIndex - 1) 
              .Take(maximumRows) 
              .ToList(); 

執行時間提到這個查詢是不是我的本地機器上,甚至1秒,同時在服務器端重新啓動後相同,但執行時間增加一天白天,並在幾天後執行失敗(有時會失敗,有時會給出結果)。

我觀察到它花了31.05秒並失敗,它花費了51.09秒並失敗。有時需要2分鐘以上才能得出結果。

我和機架空間的人交談過,但他們無法追蹤相同的原因。

編輯1:我看到下面的SQL事件探查器查詢對我的分頁查詢

SELECT 
[Project3].[Id1] AS [Id], 
[Project3].[C1] AS [C1], 
[Project3].[Id] AS [Id1], 
[Project3].[CompanyId] AS [CompanyId], 
[Project3].[CompanyLocationId] AS [CompanyLocationId], 
[Project3].[FirstName] AS [FirstName], 
[Project3].[LastName] AS [LastName], 
[Project3].[Email] AS [Email], 
[Project3].[Address1] AS [Address1], 
[Project3].[Address2] AS [Address2], 
[Project3].[City] AS [City], 
[Project3].[State] AS [State], 
[Project3].[Country] AS [Country], 
[Project3].[Zip] AS [Zip], 
[Project3].[Phone] AS [Phone], 
[Project3].[SaleDate] AS [SaleDate], 
[Project3].[Notes] AS [Notes], 
[Project3].[Cost] AS [Cost], 
[Project3].[CreatedOn] AS [CreatedOn], 
[Project3].[ModifiedOn] AS [ModifiedOn], 
[Project3].[PrimaryReviewSiteId] AS [PrimaryReviewSiteId], 
[Project3].[Id2] AS [Id2], 
[Project3].[SubscriptionTypeId] AS [SubscriptionTypeId], 
[Project3].[PlanFeeAmount] AS [PlanFeeAmount], 
[Project3].[LoginId] AS [LoginId], 
[Project3].[IndustryTypeId] AS [IndustryTypeId], 
[Project3].[CompanyName] AS [CompanyName], 
[Project3].[NumberOfLocations] AS [NumberOfLocations], 
[Project3].[LogoImageName] AS [LogoImageName], 
[Project3].[WebsiteUrl] AS [WebsiteUrl], 
[Project3].[blsActive] AS [blsActive], 
[Project3].[Pending] AS [Pending], 
[Project3].[ExpiryDate] AS [ExpiryDate], 
[Project3].[C2] AS [C2], 
[Project3].[Id3] AS [Id3], 
[Project3].[UploadTicketId] AS [UploadTicketId], 
[Project3].[UploadStatus] AS [UploadStatus], 
[Project3].[CompanyId1] AS [CompanyId1], 
[Project3].[CompanyLocationId1] AS [CompanyLocationId1], 
[Project3].[CustomerId] AS [CustomerId], 
[Project3].[CreatedOn2] AS [CreatedOn1] 
FROM (SELECT 
    [Limit2].[Id] AS [Id], 
    [Limit2].[CompanyId] AS [CompanyId], 
    [Limit2].[CompanyLocationId] AS [CompanyLocationId], 
    [Limit2].[FirstName] AS [FirstName], 
    [Limit2].[LastName] AS [LastName], 
    [Limit2].[Email] AS [Email], 
    [Limit2].[Address1] AS [Address1], 
    [Limit2].[Address2] AS [Address2], 
    [Limit2].[City] AS [City], 
    [Limit2].[State] AS [State], 
    [Limit2].[Country] AS [Country], 
    [Limit2].[Zip] AS [Zip], 
    [Limit2].[Phone] AS [Phone], 
    [Limit2].[SaleDate] AS [SaleDate], 
    [Limit2].[Notes] AS [Notes], 
    [Limit2].[Cost] AS [Cost], 
    [Limit2].[CreatedOn] AS [CreatedOn], 
    [Limit2].[ModifiedOn] AS [ModifiedOn], 
    [Limit2].[PrimaryReviewSiteId] AS [PrimaryReviewSiteId], 
    [Limit2].[Id1] AS [Id1], 
    [Limit2].[CreatedOn1] AS [CreatedOn1], 
    [Limit2].[Id2] AS [Id2], 
    [Limit2].[SubscriptionTypeId] AS [SubscriptionTypeId], 
    [Limit2].[PlanFeeAmount] AS [PlanFeeAmount], 
    [Limit2].[LoginId] AS [LoginId], 
    [Limit2].[IndustryTypeId] AS [IndustryTypeId], 
    [Limit2].[CompanyName] AS [CompanyName], 
    [Limit2].[NumberOfLocations] AS [NumberOfLocations], 
    [Limit2].[WebsiteUrl] AS [WebsiteUrl], 
    [Limit2].[blsActive] AS [blsActive], 
    [Limit2].[Pending] AS [Pending], 
    [Limit2].[ExpiryDate] AS [ExpiryDate], 
    [Limit2].[LogoImageName] AS [LogoImageName], 
    [Limit2].[C1] AS [C1], 
    [Extent4].[Id] AS [Id3], 
    [Extent4].[UploadTicketId] AS [UploadTicketId], 
    [Extent4].[UploadStatus] AS [UploadStatus], 
    [Extent4].[CompanyId] AS [CompanyId1], 
    [Extent4].[CompanyLocationId] AS [CompanyLocationId1], 
    [Extent4].[CustomerId] AS [CustomerId], 
    [Extent4].[CreatedOn] AS [CreatedOn2], 
    CASE WHEN ([Extent4].[Id] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C2] 
    FROM (SELECT TOP (20) [Project2].[Id] AS [Id], [Project2].[CompanyId] AS [CompanyId], [Project2].[CompanyLocationId] AS [CompanyLocationId], [Project2].[FirstName] AS [FirstName], [Project2].[LastName] AS [LastName], [Project2].[Email] AS [Email], [Project2].[Address1] AS [Address1], [Project2].[Address2] AS [Address2], [Project2].[City] AS [City], [Project2].[State] AS [State], [Project2].[Country] AS [Country], [Project2].[Zip] AS [Zip], [Project2].[Phone] AS [Phone], [Project2].[SaleDate] AS [SaleDate], [Project2].[Notes] AS [Notes], [Project2].[Cost] AS [Cost], [Project2].[CreatedOn] AS [CreatedOn], [Project2].[ModifiedOn] AS [ModifiedOn], [Project2].[PrimaryReviewSiteId] AS [PrimaryReviewSiteId], [Project2].[Id1] AS [Id1], [Project2].[CreatedOn1] AS [CreatedOn1], [Project2].[Id2] AS [Id2], [Project2].[SubscriptionTypeId] AS [SubscriptionTypeId], [Project2].[PlanFeeAmount] AS [PlanFeeAmount], [Project2].[LoginId] AS [LoginId], [Project2].[IndustryTypeId] AS [IndustryTypeId], [Project2].[CompanyName] AS [CompanyName], [Project2].[NumberOfLocations] AS [NumberOfLocations], [Project2].[WebsiteUrl] AS [WebsiteUrl], [Project2].[blsActive] AS [blsActive], [Project2].[Pending] AS [Pending], [Project2].[ExpiryDate] AS [ExpiryDate], [Project2].[LogoImageName] AS [LogoImageName], [Project2].[C1] AS [C1] 
     FROM (SELECT [Project2].[Id] AS [Id], [Project2].[CompanyId] AS [CompanyId], [Project2].[CompanyLocationId] AS [CompanyLocationId], [Project2].[FirstName] AS [FirstName], [Project2].[LastName] AS [LastName], [Project2].[Email] AS [Email], [Project2].[Address1] AS [Address1], [Project2].[Address2] AS [Address2], [Project2].[City] AS [City], [Project2].[State] AS [State], [Project2].[Country] AS [Country], [Project2].[Zip] AS [Zip], [Project2].[Phone] AS [Phone], [Project2].[SaleDate] AS [SaleDate], [Project2].[Notes] AS [Notes], [Project2].[Cost] AS [Cost], [Project2].[CreatedOn] AS [CreatedOn], [Project2].[ModifiedOn] AS [ModifiedOn], [Project2].[PrimaryReviewSiteId] AS [PrimaryReviewSiteId], [Project2].[Id1] AS [Id1], [Project2].[CreatedOn1] AS [CreatedOn1], [Project2].[Id2] AS [Id2], [Project2].[SubscriptionTypeId] AS [SubscriptionTypeId], [Project2].[PlanFeeAmount] AS [PlanFeeAmount], [Project2].[LoginId] AS [LoginId], [Project2].[IndustryTypeId] AS [IndustryTypeId], [Project2].[CompanyName] AS [CompanyName], [Project2].[NumberOfLocations] AS [NumberOfLocations], [Project2].[WebsiteUrl] AS [WebsiteUrl], [Project2].[blsActive] AS [blsActive], [Project2].[Pending] AS [Pending], [Project2].[ExpiryDate] AS [ExpiryDate], [Project2].[LogoImageName] AS [LogoImageName], [Project2].[C1] AS [C1], row_number() OVER (ORDER BY [Project2].[CreatedOn1] ASC) AS [row_number] 
      FROM (SELECT 
       [Filter1].[Id] AS [Id], 
       [Filter1].[CompanyId] AS [CompanyId], 
       [Filter1].[CompanyLocationId] AS [CompanyLocationId], 
       [Filter1].[FirstName] AS [FirstName], 
       [Filter1].[LastName] AS [LastName], 
       [Filter1].[Email] AS [Email], 
       [Filter1].[Address1] AS [Address1], 
       [Filter1].[Address2] AS [Address2], 
       [Filter1].[City] AS [City], 
       [Filter1].[State] AS [State], 
       [Filter1].[Country] AS [Country], 
       [Filter1].[Zip] AS [Zip], 
       [Filter1].[Phone] AS [Phone], 
       [Filter1].[SaleDate] AS [SaleDate], 
       [Filter1].[Notes] AS [Notes], 
       [Filter1].[Cost] AS [Cost], 
       [Filter1].[CreatedOn] AS [CreatedOn], 
       [Filter1].[ModifiedOn] AS [ModifiedOn], 
       [Filter1].[PrimaryReviewSiteId] AS [PrimaryReviewSiteId], 
       [Limit1].[Id] AS [Id1], 
       [Limit1].[CreatedOn] AS [CreatedOn1], 
       [Extent3].[Id] AS [Id2], 
       [Extent3].[SubscriptionTypeId] AS [SubscriptionTypeId], 
       [Extent3].[PlanFeeAmount] AS [PlanFeeAmount], 
       [Extent3].[LoginId] AS [LoginId], 
       [Extent3].[IndustryTypeId] AS [IndustryTypeId], 
       [Extent3].[CompanyName] AS [CompanyName], 
       [Extent3].[NumberOfLocations] AS [NumberOfLocations], 
       [Extent3].[WebsiteUrl] AS [WebsiteUrl], 
       [Extent3].[blsActive] AS [blsActive], 
       [Extent3].[Pending] AS [Pending], 
       [Extent3].[ExpiryDate] AS [ExpiryDate], 
       [Extent3].[LogoImageName] AS [LogoImageName], 
       1 AS [C1] 
       FROM (SELECT [Extent1].[Id] AS [Id], [Extent1].[CompanyId] AS [CompanyId], [Extent1].[CompanyLocationId] AS [CompanyLocationId], [Extent1].[FirstName] AS [FirstName], [Extent1].[LastName] AS [LastName], [Extent1].[Email] AS [Email], [Extent1].[Address1] AS [Address1], [Extent1].[Address2] AS [Address2], [Extent1].[City] AS [City], [Extent1].[State] AS [State], [Extent1].[Country] AS [Country], [Extent1].[Zip] AS [Zip], [Extent1].[Phone] AS [Phone], [Extent1].[SaleDate] AS [SaleDate], [Extent1].[Notes] AS [Notes], [Extent1].[Cost] AS [Cost], [Extent1].[CreatedOn] AS [CreatedOn], [Extent1].[ModifiedOn] AS [ModifiedOn], [Extent1].[PrimaryReviewSiteId] AS [PrimaryReviewSiteId] 
        FROM [dbo].[Customer] AS [Extent1] 
        WHERE (([Extent1].[FirstName] LIKE @p__linq__0 ESCAPE N'~') OR ([Extent1].[LastName] LIKE @p__linq__1 ESCAPE N'~') OR ([Extent1].[Email] LIKE @p__linq__2 ESCAPE N'~') OR ([Extent1].[FirstName] + N' ' + [Extent1].[LastName] LIKE @p__linq__3 ESCAPE N'~')) AND ([Extent1].[CompanyId] = @p__linq__4) AND ([Extent1].[CompanyLocationId] = @p__linq__5)) AS [Filter1] 
       OUTER APPLY (SELECT TOP (1) 
        [Extent2].[Id] AS [Id], 
        [Extent2].[CreatedOn] AS [CreatedOn] 
        FROM [dbo].[EmailCampaignerStatus] AS [Extent2] 
        WHERE [Filter1].[Id] = [Extent2].[CustomerId]) AS [Limit1] 
       LEFT OUTER JOIN [dbo].[Company] AS [Extent3] ON [Filter1].[CompanyId] = [Extent3].[Id] 
      ) AS [Project2] 
     ) AS [Project2] 
     WHERE [Project2].[row_number] > 0 
     ORDER BY [Project2].[CreatedOn1] ASC) AS [Limit2] 
    LEFT OUTER JOIN [dbo].[EmailCampaignerStatus] AS [Extent4] ON [Limit2].[CompanyId] = [Extent4].[CompanyId] 
) AS [Project3] 
ORDER BY [Project3].[CreatedOn1] ASC, [Project3].[Id1] ASC, [Project3].[Id] ASC, [Project3].[Id2] ASC, [Project3].[C2] ASC 

SELECT 
[GroupBy1].[A1] AS [C1] 
FROM (SELECT 
    COUNT(1) AS [A1] 
    FROM [dbo].[Customer] AS [Extent1] 
    WHERE (([Extent1].[FirstName] LIKE @p__linq__0 ESCAPE N'~') OR ([Extent1].[LastName] LIKE @p__linq__1 ESCAPE N'~') OR ([Extent1].[Email] LIKE @p__linq__2 ESCAPE N'~') OR ([Extent1].[FirstName] + N' ' + [Extent1].[LastName] LIKE @p__linq__3 ESCAPE N'~')) AND ([Extent1].[CompanyId] = @p__linq__4) AND ([Extent1].[CompanyLocationId] = @p__linq__5) 
) AS [GroupBy1] 


SELECT 
CASE WHEN (EXISTS (SELECT 
    1 AS [C1] 
    FROM [dbo].[CompanyReviewSites] AS [Extent1] 
    WHERE [Extent1].[CompanyLocationId] = @p__linq__0 
)) THEN cast(1 as bit) WHEN (NOT EXISTS (SELECT 
    1 AS [C1] 
    FROM [dbo].[CompanyReviewSites] AS [Extent2] 
    WHERE [Extent2].[CompanyLocationId] = @p__linq__0 
)) THEN cast(0 as bit) END AS [C1] 
FROM (SELECT 1 AS X) AS [SingleRowTable1] 

SELECT 
1 AS [C1], 
[Extent1].[Id] AS [Id], 
[Extent1].[RiviewSiteId] AS [RiviewSiteId], 
[Extent1].[URL] AS [URL], 
[Extent1].[CompanyId] AS [CompanyId], 
[Extent1].[CompanyLocationId] AS [CompanyLocationId], 
[Extent2].[Id] AS [Id1], 
[Extent2].[ReviewSiteName] AS [ReviewSiteName], 
[Extent2].[ImageName] AS [ImageName] 
FROM [dbo].[CompanyReviewSites] AS [Extent1] 
INNER JOIN [dbo].[ReviewSites] AS [Extent2] ON [Extent1].[RiviewSiteId] = [Extent2].[Id] 
WHERE [Extent1].[CompanyLocationId] = @p__linq__0 
+1

你看到這個線程http://stackoverflow.com/questions/1421978/help-troubleshooting-sqlexception-超時已過期未加載連接 – VJAI

+0

已檢查,但沒有內存和預定作業(SQL代理作業)問題。我在機器上安裝了8GB RAM。 –

+0

您使用SQL Server * Express *數據庫還是常規SQL Server版本? – Slauma

回答

2

可能有很多原因的:

  • 從失敗的交易
  • 的鎖索引問題
  • 如果它是共享服務器,則從另一個應用程序競爭資源
  • 備份不清除事務日誌
  • 相關磁盤空間問題

您能夠獲得SQL服務器日誌,查看活動監視器或運行SQL事件探查器。從我的經驗這樣的問題是非常難以追查,所以只能祝你好運

+0

我已經在相關表格中創建了索引,其雲服務器意味着一臺專用機器。關於「備份不清除事務日誌」,如何檢查?我沒有創建任何備份,可用磁盤空間爲290 GB。我已經提到了SQL查詢,在SQL Profiler中我已經看到了這個查詢。 –

+0

@JitendraPancholi事務日誌僅在完整備份時清除。此外,什麼是分析器報告。最後,你是否嘗試過在服務器上手動運行查詢。 –

+0

其實奇怪的是,它現在沒有來,因爲我昨天重新啓動了服務器。可能會在幾天後回來。並且我運行了從SQL事件探查器獲得的查詢,並且在Sql server management studio的服務器上執行的時間不到1秒。 –

0

我認爲這是索引和刷新所有索引臨時數據的問題..這被稱爲統計數據,當SQL服務器收集所有緩存的可變變化,所以它將它們用作索引服務的現金。在SQL數據庫中,以便更新的統計數據或許可以幫忙,

DECLARE @SQL VARCHAR(1000) 
DECLARE @DB sysname 

DECLARE curDB CURSOR FORWARD_ONLY STATIC FOR 
    SELECT [name] 
    FROM master..sysdatabases 
    WHERE [name] NOT IN ('model', 'tempdb') 
    ORDER BY [name] 

OPEN curDB 
FETCH NEXT FROM curDB INTO @DB 
WHILE @@FETCH_STATUS = 0 
    BEGIN 
     SELECT @SQL = 'USE [' + @DB +']' + CHAR(13) + 'EXEC sp_updatestats' + CHAR(13) 
     PRINT @SQL 
     FETCH NEXT FROM curDB INTO @DB 
    END 

CLOSE curDB 
DEALLOCATE curDB 

然後執行查詢...

0

有幾件事情映入腦海。你是否運行負載測試?它在你的機器和服務器上都可以獨立運行,但是在幾天之後有幾千次命中,那麼它可能是另一回事。這似乎是你提到的行爲。

也許第一個查詢只有200行,但第三天的相同查詢必須搜索200萬,這會讓事情變慢一點。

正如其他人所建議的。看看改進你的數據庫表上的索引(如果這是一個選項)。

是否可以重新編寫Linq查詢。也許寫它的方式是阻止SQL緩存RAM中的查詢執行計劃。

服務器本身是否備份?當託管公司通過拍攝我們的數據庫所在的虛擬機的快照來影響工作時,我已經有了實例,而不是基於雲的服務器。

2

當我遇到類似的問題;我們的服務器幾乎索引了每一個查詢。同樣,在整個公司大量使用後,它也會出現類似的問題。我通過以下方式解決了這個問題:

處理臨時對象/用using語句包裝。這使我可以保留存儲在內存中的任何對象,查詢或任何數據以便轉儲。

另一個問題;是我們的開發者之一在整個應用程序中不斷打開/關閉連接。我試圖創建這個用法;打開一次,然後立即完成所有需要的任務。這可能會迫使一些重新設計;但它保持更強勁。即使每個班級都沒有打開/關閉;但是當你準備好提交,然後在課堂開放的時候添加所需的課程也可能有幫助。

下一個困境是驗證所有緩存項目被清除。所以你不要經常存儲它。

另一項是改變我們的Windows虛擬機索引。

用於處置的實例/使用: http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx

public void SqlTransactionHere() 
{ 
     SqlTransaction tran = myConnection.BeginTransaction(); 
     tran.Dispose(); 
} 

一個例子以幫助保持連接;然後做我們的電話,我們採用類似的模式:

http://msdn.microsoft.com/en-us/magazine/cc947917.aspx

一些調整,我們確實做了我們的服務器;因爲我們的服務器開始分頁並在內存中存儲太多數據,這些數據也陷入了困境。

您可以監控您的服務器;通過執行下列步驟操作:

  1. Windows鍵+ R(運行)
  2. Powershell的
  3. 然後鍵入:

    將strComputer = 「 - 」 集objWmiService = GetObject的( 「winmgmts:\」 & strComputer的& 「\根\ CIMV2」) 集colPageFiles = objWMIService.ExecQuery( 「SELECT * FROM Win32_PageFileSetting」)

    EA的CH objPageFile在colPageFiles objPageFile.InitialSize = 384 objPageFile.MaximumSize = 1152 objPageFile.Put_ 接着

以上是256MB RAM; 「微軟最好的」。我們實際上把我們的初始尺寸降到了50;最大尺寸爲384.我們的服務器在開始時標記錯誤,表明我們將虛擬內存設置得太低。然而;我們的服務器性能與我們的應用程序一樣增加。您可以實際監控其內存使用情況/虛擬內存使用情況,以幫助計算。

如果你想寫一個應用程序太監視和記錄你;或者想使用微軟的內置控件: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.virtualmemorysize64.aspx

  1. 開始
  2. 管理工具(如果不存在,控制面板 - >管理工具)
  3. 系統監控
  4. 頁面文件,以及其他組件監視。 %然後添加使用
  5. 應該開始爲您追蹤。

你也可以改變它在註冊表中:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management 

您也可以清除緩存。這可以通過使用來完成:

  • DBCC DROPCLEANBUFFERS
  • CHECKPOINT

他們可以幫助清除一些緩存相關的問題;重新啓動SQL Server或Windows完成同樣的事情。這就是爲什麼它可以解決你的問題。但再次發生;如果太長了。

下面是SQL腳本的性能有很大的文章:

http://sqlcat.com/sqlcat/b/toolbox/archive/2008/02/21/scripts-and-tools-for-performance-tuning-and-troubleshooting-sql-server-2005.aspx

這篇文章是一個很好的人來幫助解決或找到性能問題: http://support.microsoft.com/kb/298475

或者,如果你不覺得就像做這些事情一樣,因爲它正在工作,但是在使用和大量使用數天後確實會拋出異常。你可以簡單地創建一個powershell腳本;搭配:

腳本: 「設置在一個時間的計劃表」 重啓電腦-ComputerName本地主機

然後就到你的註冊地:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon 
  1. 用鼠標雙擊DefaultUserName
  2. 輸入服務器登錄
  3. 雙擊DefaultPassword
  4. 把你[R密碼。
  5. 變化AutoAdminLogin值1

您可以編輯,或添加字符串值也是如此。如果它不存在。

希望那些幫助你;那些是我們爲了解決我們的問題而必須做的一些事情。你可能只需要做一個,或沒有。但我希望能夠幫助或給社區一些想法,以幫助更好地解決您的問題。

但是對我來說,聽起來好像你的服務器內存正在停滯,數據太多,並且它無法在機器陷入困境時解析或運行命令。我假設你使用Windows Server,如果不是那些Powershell腳本命令是無用的。

相關問題