2013-10-11 56 views
0

我無法讓我的應用程序可靠地連接到一個鏡像的SQL Server 2008 R2的可靠連接UNPOOLED。我創建了一個工具來幫助診斷問題並發現了一些有趣的事情。問題越來越到SQL Server 2008R2

我使用的連接字符串

Data Source=IADB01;Failover Partner=IBDB01;Database=XXX; 
Integrated Security=SSPI;Connection Timeout=150;Pooling=false; 

這似乎是對非池連接字符串。如果我離開游泳池,我一點問題都沒有,並且每秒可以產生幾百個連接而沒有任何問題。但是這會導致自動故障轉移的問題。隨着池關閉,我終於此SQLException之前0和100個左右的成功連接,然後長時間的延遲之間獲得:

System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'INTERNET\71260'. 
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) 
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) 
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) 
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) 
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) 
at System.Data.SqlClient.SqlInternalConnectionTds.LoginWithFailover(Boolean useFailoverHost, ServerInfo primaryServerInfo, String failoverHost, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) 
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) 
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) 
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) 
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) 
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) 
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) 
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) 
at System.Data.SqlClient.SqlConnection.Open() 
at DatabaseConnectionTest.Form1.MakeConnection() 
ClientConnectionId:dc55aea9-ea36-4812-b628-3dc7f096f0e4 

我想不通這是我不知道爲什麼異常登錄失敗。如果我再次開始連接,則在再次登錄失敗之前,我可以獲得0到大約100次左右的任何成功連接。我看不出有什麼模式可以告訴我在失敗之前獲得了多少成功的連接,但它通常只有5-10次成功。我們已經將客戶端轉移到與數據庫服務器相同的網絡交換機上,以避免防火牆等問題發生,並且沒有任何改變。 DC也在同一臺交換機上。

成功連接正在不到一秒。當一個連接失敗時,它只會在至少5秒後有時達到20秒。我確信這個問題還在其他地方,但我需要關於在哪裏尋找的想法。

我可以在事件日誌看到的SQL Server使得它的電話,但條目是始終不變的。發生故障時,我在事件日誌中獲得了相同的一組呼叫。我想在SQL Server上使用探查器來查看,但是由於沒有系統管理員,我一直無法訪問。

所以,儘可能的堆棧跟蹤去,它看起來像它的儘可能使其作爲方法運行和TryRun。我應該如何理解?連接實際上已經建立,但是然後命令失敗了?謝謝您的幫助。如果需要,我可以發佈更多。

+0

猜測:選中該設置:http://technet.microsoft.com/en-us/library/ms187030.aspx – granadaCoder

+0

我檢查的第一件事。這是默認的0 - 無限制。 – MJM

回答

0

排序。這是由TCP煙囪卸載造成的已知問題。解決方案是關閉卸載。