From d9999d6f2b7f7d694b07752a083e2991ebd28b0f Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Tue, 21 Jul 2020 14:28:37 -0700 Subject: [PATCH] [Release/2.0] Fix transient fault handling for Pooled connections (#638) --- .../src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs | 4 +++- .../src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs index 432089972e..e6c26f06dd 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs @@ -545,6 +545,8 @@ private bool IsTransientError(SqlException exc) { if (s_transientErrors.Contains(error.Number)) { + // When server timeouts, connection is doomed. Reset here to allow reconnect. + UnDoomThisConnection(); return true; } } @@ -1629,7 +1631,7 @@ private bool AttemptRetryADAuthWithTimeoutError(SqlException sqlex, SqlConnectio timeout.Reset(); // When server timeout, the auth context key was already created. Clean it up here. _dbConnectionPoolAuthenticationContextKey = null; - // When server timeout, connection is doomed. Reset here to allow reconnect. + // When server timeouts, connection is doomed. Reset here to allow reconnect. UnDoomThisConnection(); // Change retry state so it only retries once for timeout error. _activeDirectoryAuthTimeoutRetryHelper.State = ActiveDirectoryAuthenticationTimeoutRetryState.Retrying; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs index 0dd2ba82e5..eafcda9ee9 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs @@ -633,6 +633,8 @@ private bool IsTransientError(SqlException exc) { if (transientErrors.Contains(error.Number)) { + // When server timeouts, connection is doomed. Reset here to allow reconnect. + UnDoomThisConnection(); return true; } } @@ -1977,7 +1979,7 @@ private bool AttemptRetryADAuthWithTimeoutError(SqlException sqlex, SqlConnectio timeout.Reset(); // When server timeout, the auth context key was already created. Clean it up here. _dbConnectionPoolAuthenticationContextKey = null; - // When server timeout, connection is doomed. Reset here to allow reconnect. + // When server timeouts, connection is doomed. Reset here to allow reconnect. UnDoomThisConnection(); // Change retry state so it only retries once for timeout error. _activeDirectoryAuthTimeoutRetryHelper.State = ActiveDirectoryAuthenticationTimeoutRetryState.Retrying;