Skip to content

Commit

Permalink
chore: improve retry logging at debug level
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Aug 29, 2024
1 parent fee9441 commit ba8fd2b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/CommonLib/LdapConnectionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public async IAsyncEnumerable<LdapResult<IDirectoryObject>> 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++) {
Expand Down Expand Up @@ -144,6 +145,7 @@ public async IAsyncEnumerable<LdapResult<IDirectoryObject>> 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) {
Expand Down Expand Up @@ -258,7 +260,9 @@ public async IAsyncEnumerable<LdapResult<IDirectoryObject>> 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);
Expand Down Expand Up @@ -286,6 +290,7 @@ public async IAsyncEnumerable<LdapResult<IDirectoryObject>> 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) {
Expand Down Expand Up @@ -423,11 +428,13 @@ public async IAsyncEnumerable<Result<string>> 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);
Expand Down

0 comments on commit ba8fd2b

Please sign in to comment.