From ba8fd2b6ec5a1170cf062f317a9ffad244c1b11e Mon Sep 17 00:00:00 2001 From: rvazarkar Date: Thu, 29 Aug 2024 15:46:05 -0400 Subject: [PATCH] chore: improve retry logging at debug level --- src/CommonLib/LdapConnectionPool.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/CommonLib/LdapConnectionPool.cs b/src/CommonLib/LdapConnectionPool.cs index 490806cb..fe0cb5a7 100644 --- a/src/CommonLib/LdapConnectionPool.cs +++ b/src/CommonLib/LdapConnectionPool.cs @@ -114,6 +114,7 @@ public async IAsyncEnumerable> Query(LdapQueryParam * since non-paged queries do not require same server connections */ queryRetryCount++; + _log.LogDebug("Query - Attempting to recover from ServerDown for query {Info} (Attempt {Count})", queryParameters.GetQueryInfo(), queryRetryCount); ReleaseConnection(connectionWrapper, true); for (var retryCount = 0; retryCount < MaxRetries; retryCount++) { @@ -144,6 +145,7 @@ public async IAsyncEnumerable> Query(LdapQueryParam * The expectation is that given enough time, the server should stop being busy and service our query appropriately */ busyRetryCount++; + _log.LogDebug("Query - Executing busy backoff for query {Info} (Attempt {Count})", queryParameters.GetQueryInfo(), busyRetryCount); var backoffDelay = GetNextBackoff(busyRetryCount); await Task.Delay(backoffDelay, cancellationToken); } catch (LdapException le) { @@ -258,7 +260,9 @@ public async IAsyncEnumerable> PagedQuery(LdapQuery ReleaseConnection(connectionWrapper, true); yield break; } - + + _log.LogDebug("PagedQuery - Attempting to recover from ServerDown for query {Info} (Attempt {Count})", queryParameters.GetQueryInfo(), queryRetryCount); + ReleaseConnection(connectionWrapper, true); for (var retryCount = 0; retryCount < MaxRetries; retryCount++) { var backoffDelay = GetNextBackoff(retryCount); @@ -286,6 +290,7 @@ public async IAsyncEnumerable> PagedQuery(LdapQuery * The expectation is that given enough time, the server should stop being busy and service our query appropriately */ busyRetryCount++; + _log.LogDebug("PagedQuery - Executing busy backoff for query {Info} (Attempt {Count})", queryParameters.GetQueryInfo(), busyRetryCount); var backoffDelay = GetNextBackoff(busyRetryCount); await Task.Delay(backoffDelay, cancellationToken); } catch (LdapException le) { @@ -423,11 +428,13 @@ public async IAsyncEnumerable> RangedRetrieval(string distinguish response = (SearchResponse)connectionWrapper.Connection.SendRequest(searchRequest); } catch (LdapException le) when (le.ErrorCode == (int)ResultCode.Busy && busyRetryCount < MaxRetries) { busyRetryCount++; + _log.LogDebug("RangedRetrieval - Executing busy backoff for query {Info} (Attempt {Count})", queryParameters.GetQueryInfo(), busyRetryCount); var backoffDelay = GetNextBackoff(busyRetryCount); await Task.Delay(backoffDelay, cancellationToken); } catch (LdapException le) when (le.ErrorCode == (int)LdapErrorCodes.ServerDown && queryRetryCount < MaxRetries) { queryRetryCount++; + _log.LogDebug("RangedRetrieval - Attempting to recover from ServerDown for query {Info} (Attempt {Count})", queryParameters.GetQueryInfo(), queryRetryCount); ReleaseConnection(connectionWrapper, true); for (var retryCount = 0; retryCount < MaxRetries; retryCount++) { var backoffDelay = GetNextBackoff(retryCount);