2013-04-03 21 views
0

我們在Azure中託管的網站定期拋出異常,當有多個用戶同時使用系統(15-25個用戶)並檢索併發布來自到數據庫。該異常與連接到數據庫有關。通過使用linq到sql的網站進行SQL Azure連接的問題

我們正在使用Azure SQL和Linq to SQL。我已經檢查過數據庫的監視器,並且沒有關於失敗連接的報告,連接數量也應該能夠處理。

我正在使用IoC容器來創建datacontext的新實例,它只是一個正在啓動的datacontext實例,並且正在用於查詢所有表。

我已經挖成事件日誌,發現被拋出的異常:


事件代碼:3005 事件消息:發生未處理的異常。 事件時間:2013年4月2日11時48分45秒 事件時間(UTC):2013年4月2日11時48分45秒 事件ID:09157c3457904c99b2b57abb44bef857 事件序列:5911 事件發生:74 事件詳細信息代碼:0

應用程序信息: 應用程序域:/ LM/W3SVC/1273337584/ROOT-1-130093075659455176 信任級別:全 應用程序虛擬路徑:/ 應用程序路徑:E:\ sitesroot \ 0 \ 機名稱:RD00155D36AB20

工藝信息: 個進程ID:2420 進程名:w3wp.exe 帳戶名:NT AUTHORITY \ NETWORK SERVICE

異常信息: 異常類型:SQLEXCEPTION 異常消息:該服務正忙。 10秒後重試請求。事件ID:{26F49B32-6DD8-4149-89FA-780AF4BD74D3}。代碼:32771 當前命令發生嚴重錯誤。如果有的話,結果應該被丟棄。 在System.Data.SqlClient.SqlConnection.OnError(SqlException異常,布爾breakConnection) 在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() 在System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand的cmdHandler,SqlDataReader的數據流,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj) 在System.Data.SqlClient.SqlDataReader.ConsumeMetaData() 在System.Data.SqlClient.SqlDataReader.get_MetaData() 在System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader的DS,RunBehavior runBehavior,String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async) at System.Data.Sq lClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method,DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method) at System.Data .SqlClient.SqlCommand.ExecuteReader(CommandBehavior行爲,字符串方法) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Linq.SqlClient.SqlProvider。執行(表達式查詢,QueryInfo queryInfo,IObjectReaderFactory工廠,Object [] parentArgs,Object [] userArgs,ICompiledSubQuery [] subQueries,Object lastResult) at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query,QueryInfo [] queryInfos ,IObjectReaderFactory factory,Object [] userArguments,ICompiledSubQuery [] subQueries) at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) at System.Data.Linq.DataQuery 1.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable 1源,Expression`1謂詞) 在Holte.UK.Service.People.PersonServiceCRUD.GetCompanyIdByUserProfile(對象用戶ID) 在Holte.UK.MvcApplication.Application_PostAcquireRequestState(對象發件人,EventArgs的) 在System.Web.HttpApplication。 SyncEventExecutionStep.System.Web.HttpApplication.IExe cutionStep.Execute() 在System.Web.HttpApplication.ExecuteStep(IExecutionStep步驟,布爾& completedSynchronously)

請求信息: 請求URL:http://www.x.x/ 請求路徑:/ 用戶主機地址:XXXX 用戶:
通過身份驗證:假 身份驗證類型:
線程帳戶名:NT AUTHORITY \ NETWORK SERVICE

線程信息: 線程ID:20 線程帳戶名:NT AUTHORITY \ NETWORK SERVICE 正在模擬:假 堆棧跟蹤:在System.Data.SqlClient.SqlConnection.OnError(SqlException異常,布爾breakConnection) 在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() 在System.Data.SqlClient.TdsParser.Run(runBehavior runBehavior,SqlCommand的cmdHandler,SqlDataReader的數據流,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj) 在System.Data.SqlClient.SqlDataReader.ConsumeMetaData() 在System.Data.SqlClient.SqlDataReader.get_MetaData () at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(C ommandBehavior cmdBehavior,RunBehavior runBehavior,布爾returnStream,布爾異步) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method,DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader (CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String方法) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior,String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System。 Data.Linq.SqlClient.SqlProvider.Execute(Expression query,QueryInfo queryInfo,IObjectReaderFactory factory,Object [] parentArgs,Object [] userArgs,ICompiledSubQuery [] subQueries,Object lastResult) at System.Data.Linq.SqlCl ient.SqlProvider.ExecuteAll at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query,QueryInfo [] queryInfos,IObjectReaderFactory factory,Object [] userArguments,ICompiledSubQuery [] subQueries) (表達式查詢) 在System.Data.Linq.DataQuery 1.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable 1種源,Expression`1謂詞) 在Holte.UK.Service.People.PersonServiceCRUD.GetCompanyIdByUserProfile(對象用戶ID) 在Holte.UK.MvcApplication.Application_PostAcquireRequestState(對象發件人,EventArgs e) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication。ExecuteStep(IExecutionStep一步,布爾& completedSynchronously)

自定義事件詳細信息:


事件代碼:3005 事件消息:發生未處理的異常。 事件時間:2013年4月2日11時46分56秒 事件時間(UTC):2013年4月2日11時46分56秒 事件ID:a8dc5c34109e4a7d9f1c74bb697d86b8 事件序列:5905 事件發生:72 事件詳細信息代碼:0

應用程序信息: 應用程序域:/ LM/W3SVC/1273337584/ROOT-1-130093075659455176 信任級別:全 應用程序虛擬路徑:/ 應用程序路徑:E:\ sitesroot \ 0 \ 機名稱:RD00155D36AB20

工藝信息: 個進程ID:2420 進程名:w3wp.exe 帳戶名:NT AUTHORITY \ NETWORK SERVICE

異常信息: 異常類型:SQLEXCEPTION 異常消息:從所述服務器接收結果時發生傳輸級錯誤。 (provider:TCP Provider,錯誤:0 - 現有連接被遠程主機強制關閉。) at System.Data.SqlClient.SqlConnection.OnError(SqlException異常,Boolean breakConnection) at System.Data.SqlClient.TdsParser。 ThrowExceptionAndWarning() 在System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj,UInt32的誤差) 在System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult,TdsParserStateObject stateObj) 在System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket () at System.Data.SqlClient.TdsParserStateObject.ReadByte() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stat eObj) 在System.Data.SqlClient.SqlDataReader.ConsumeMetaData() 在System.Data.SqlClient.SqlDataReader.get_MetaData() 在System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader的DS,RunBehavior runBehavior,字符串resetOptionsString) System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method,DbAsyncResult result)在System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean返回流,布爾異步) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior,字符串方法) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query,QueryInfo queryInfo,IObjectReaderFactory factory,Object [] parentArgs,Object [] userArgs ,ICompiledSubQuery [] subQueries,Object lastResult) at System.Data。 at System.Data.Org.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query,QueryInfo [] queryInfos,IObjectReaderFactory factory,Object [] userArguments,ICompiledSubQuery [] subQueries) Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) at System.Data.Linq.DataQuery 1.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable 1 source,Expression`1 predicate) at Holte.UK.Service.People.PersonServiceCRUD 。GetCompanyIdByUserProfile(對象用戶ID) 在Holte.UK.MvcApplication.Application_PostAcquireRequestState(對象發件人,EventArgs的) 在System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在System.Web.HttpApplication。 ExecuteStep(IExecutionStep一步,布爾& completedSynchronously)

索取信息: 請求URL:http://www.x.x/ 請求路徑:/ 用戶主機地址:XXXX 用戶:
通過身份驗證:假 身份驗證類型:
線程帳戶名:NT AUTHORITY \ NETWORK SERVICE

線程信息: 線程ID:20 線程帳戶名:NT AUTHORITY \ NETWORK SERVICE 正在模擬:假 堆棧跟蹤:在System.Data.SqlClient.SqlConnection。的OnError(SqlException異常,布爾breakConnection) 在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() 在System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj,UInt32的錯誤) 在System.Data.SqlClient.TdsParserStateObject.ReadSni (DbAsyncResult asyncResult,TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParserStateObject.R eadNetworkPacket() 在System.Data.SqlClient.TdsParserStateObject.ReadByte() 在System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand的cmdHandler,SqlDataReader的數據流,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj) 在System.Data.SqlClient的System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString)上System.Data.SqlClient.SqlDataReader.get_MetaData() 在System.Data.SqlClient.SqlCommand上的。 RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,布爾異步) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,St ring方法,DbAsyncResult結果) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior,String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query,QueryInfo queryInfo,IObjectReaderFactory factory,Object [] parentArgs,Object [] userArgs,ICompiledSubQuery [] subQueries ,Object lastResult) at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query,QueryInfo [] queryInfos,IObjectReaderFactory factory,Object [] userArguments,ICompiledSubQuery [] subQueries) at System.Data.Linq.SqlClient.SqlProvider .System.Data.Linq.Provid er.IProvider.Execute(Expression query) at System.Data.Linq.DataQuery 1.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable 1 source,Expression`1 predicate) at Holte.UK.Service.People.PersonServiceCRUD.GetCompanyIdByUserProfile(Object userID) at Holte.UK。 MvcApplication.Application_PostAcquireRequestState(Object sender,EventArgs e) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication。ExecuteStep(IExecutionStep一步,布爾& completedSynchronously)

自定義事件詳細信息:


事件代碼:3005 事件消息:發生未處理的異常。 事件時間:2013年4月2日11點20分十一秒 事件時間(UTC):2013年4月2日11點20分十一秒 事件ID:cbf42c3adf63405293a803cb75577076 事件序列:5652 事件發生:71 事件詳細信息代碼:0

應用程序信息: 應用程序域:/ LM/W3SVC/1273337584/ROOT-1-130093075659455176 信任級別:全 應用程序虛擬路徑:/ 應用程序路徑:E:\ sitesroot \ 0 \ 機名稱:RD00155D36AB20

工藝信息: 個進程ID:2420 進程名:w3wp.exe 帳戶名:NT AUTHORITY \ NETWORK SERVICE

異常信息: 異常類型:SQLEXCEPTION 異常消息:數據庫服務器上 'XXX' 'XXX' 是當前不可用。請稍後重試連接。如果問題仍然存在,請聯繫客戶支持,併爲他們提供會話跟蹤ID「30b6d33f-4976-44b8-a586-8bfe2bc66182」。 用戶'xxx'登錄失敗。 在System.Data.ProviderBase.DbConnectionPool.GetConnection(的DbConnection owningObject) 在System.Data.ProviderBase.DbConnectionFactory.GetConnection(的DbConnection owningConnection) 在System.Data.ProviderBase.DbConnectionClosed.OpenConnection(的DbConnection outerConnection,DbConnectionFactory connectionFactory的) 在System.Data.SqlClient.SqlConnection.Open() at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user) at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe() at System.Data.Linq .SqlClient.SqlProvider.InitializeProviderMode() at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) at System.Data.Linq.DataQuery 1.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable 1源,Expression`1謂詞) 在Holte.UK.Service.People.PersonServiceCRUD.GetCompanyIdByUserProfile(對象用戶ID) 在Holte.UK.MvcApplication.Application_PostAcquireRequestState(對象發件人,EventArgs的) 在System.Web.HttpApplication。 SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在System.Web.HttpApplication.ExecuteStep(IExecutionStep一步,布爾& completedSynchronously)

索取信息: 請求URL:http://mail.x.x/FindInspector/Companies/128?InspectorCompaniesViewModel-page=5&InspectorCompaniesViewModel-sort=Telephone-asc 請求路徑:/ FindInspector /公司/ 128 用戶主機地址:66.249.76.91 用戶:
通過身份驗證:假 身份驗證類型:
線程帳戶名:NT AUTHORITY \ NETWORK SERVICE

線程信息: 線程ID:21 線程帳戶名:NT AUTHORITY \ NETWORK SERVICE 正在模擬:假 堆棧跟蹤:在System.Data.ProviderBase.DbConnectionPool。的getConnection(的DbConnection owningObject) 在System.Data.ProviderBase.DbConnectionFactory.GetConnection(的DbConnection owningConnection) 在System.Data.ProviderBase.DbConnectionClosed.OpenConnection(的DbConnection outerConnection,DbConnectionFactory connectionFactory的) 在System.Data.SqlClient.SqlConnection.Open( ) 在System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser用戶) 在System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe() 在System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode() 在System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) at System.Data.Linq.DataQuery 1.System.Linq.IQueryProvider.Execute[S](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable 1 source,Expression`1 predicate) at Holte.UK.Service.People.PersonServiceCRUD.GetCompanyIdByUserProfile(Object userID) at Holte.UK.MvcApplication.Application_PostAcquireRequestState(Object sender,EventArgs e) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep .Execute() 在System.Web.HttpApplication.ExecuteStep(IExecutionStep一步,布爾& completedSynchronously)

自定義事件詳細信息:

回答

2

這些是在SQL Azure中很常見transient條件。我想你沒有在你的代碼中實現任何重試邏輯。

在應用程序中查看並閱讀並實現「瞬態故障處理」。

+1

儘管發生了暫時性錯誤,但它們不應該定期發生。我想知道從webroles到數據庫的數據庫邏輯是否太頻繁/未優化 – Igorek

+0

謝謝,我會研究這些修復。它發生的頻率非常高,所以這個問題可能是因爲我使用了datacontext的一個實例,用於查詢並管理數據庫中的每個表。我見過的最佳做法是使用具有事務範圍和datacontext的using語句來執行每一項操作,而不是像我現在那樣只有一個datacontext實例,這是否會成爲問題? –

+0

我也總是在數據上下文周圍使用'using'塊... – astaykov

0

從我的理解,如果你得到與否這個問題上可以說是相當隨機的。在一臺SQL服務器上運行大約600個Azure SQL安裝/實例。 Azure安裝在該服務器上共享所有資源,mdf和ldf文件(這就是爲什麼您必須聯繫支持來恢復您的數據庫)。因此,如果你運氣不好並最終進入某個使用大量數據庫操作的服務器,那麼這將影響Azure SQL的性能。

如果你不走運並且出現暫時錯誤,另一個解決方案可能是創建一個新的Azure SQL並在那裏移動你的數據庫。希望這會將您的新Azure SQL放置在不同的服務器上,並且使用服務器的其他操作系統的負載較輕。