@@ -286,8 +286,6 @@ public async IAsyncEnumerable<LdapResult<IDirectoryObject>> PagedQuery(LdapQuery
286286 if ( response != null ) {
287287 pageResponse = ( PageResultResponseControl ) response . Controls
288288 . Where ( x => x is PageResultResponseControl ) . DefaultIfEmpty ( null ) . FirstOrDefault ( ) ;
289- // Reset retry counter on a successful response so the next page gets a fresh budget
290- queryRetryCount = 0 ;
291289 } else if ( queryRetryCount == MaxRetries ) {
292290 _metric . Observe ( LdapMetricDefinitions . FailedRequests , 1 ,
293291 new LabelValues ( [ nameof ( LdapConnectionPool ) , _poolIdentifier ] ) ) ;
@@ -413,8 +411,9 @@ public async IAsyncEnumerable<LdapResult<IDirectoryObject>> PagedQuery(LdapQuery
413411 continue ;
414412 }
415413
416- // Reset busy retry count after a successfully delivered page so each page starts with a fresh budget
414+ // Reset busy and query retry count after a successfully delivered page so each page starts with a fresh budget
417415 busyRetryCount = 0 ;
416+ queryRetryCount = 0 ;
418417
419418 foreach ( SearchResultEntry entry in response . Entries ) {
420419 if ( cancellationToken . IsCancellationRequested ) {
@@ -581,6 +580,8 @@ public async IAsyncEnumerable<Result<string>> RangedRetrieval(string distinguish
581580 * If we get a busy error, we want to do an exponential backoff, but maintain the current connection.
582581 * The expectation is that given enough time, the server should stop being busy and service our query appropriately.
583582 */
583+ _metric . Observe ( LdapMetricDefinitions . FailedRequests , 1 ,
584+ new LabelValues ( [ nameof ( LdapConnectionPool ) , _poolIdentifier ] ) ) ;
584585 busyRetryCount ++ ;
585586 _log . LogDebug ( "RangedRetrieval - Executing busy backoff for query {Info} (Attempt {Count})" ,
586587 queryParameters . GetQueryInfo ( ) , busyRetryCount ) ;
@@ -591,6 +592,8 @@ public async IAsyncEnumerable<Result<string>> RangedRetrieval(string distinguish
591592 /*
592593 * Treat a timeout as a busy error
593594 */
595+ _metric . Observe ( LdapMetricDefinitions . FailedRequests , 1 ,
596+ new LabelValues ( [ nameof ( LdapConnectionPool ) , _poolIdentifier ] ) ) ;
594597 busyRetryCount ++ ;
595598 _log . LogDebug ( "RangedRetrieval - Timeout: Executing busy backoff for query {Info} (Attempt {Count})" ,
596599 queryParameters . GetQueryInfo ( ) , busyRetryCount ) ;
0 commit comments