From 74b51f0192675027a096f89069119961d6b4c521 Mon Sep 17 00:00:00 2001 From: Stephanie Huynh Date: Thu, 14 Dec 2023 07:50:01 -0800 Subject: [PATCH] feat: do not move requests to pending if the batch failed when using queue batches (#1181) --- src/services/anchor-service.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/services/anchor-service.ts b/src/services/anchor-service.ts index 247728642..25f320c82 100644 --- a/src/services/anchor-service.ts +++ b/src/services/anchor-service.ts @@ -273,13 +273,17 @@ export class AnchorService { await logAnchorSummary(this.requestRepository, groupedRequests, candidates, results) return } catch (err) { - logger.warn( - `Updating PROCESSING requests to PENDING so they are retried in the next batch because an error occurred while creating the anchors: ${err}` - ) const acceptedRequests = candidates.map((candidate) => candidate.request).flat() - await this.requestRepository.updateRequests({ status: RS.PENDING }, acceptedRequests) - Metrics.count(METRIC_NAMES.REVERT_TO_PENDING, acceptedRequests.length) + // If we are using queued batches, the queue will retry the entire batch. Status updates are not needed for retry. + if (!this.useQueueBatches) { + logger.warn( + `Updating PROCESSING requests to PENDING so they are retried in the next batch because an error occurred while creating the anchors: ${err}` + ) + await this.requestRepository.updateRequests({ status: RS.PENDING }, acceptedRequests) + + Metrics.count(METRIC_NAMES.REVERT_TO_PENDING, acceptedRequests.length) + } // groupRequests.failedRequests does not include all the newly failed requests so we recount here const failedRequests = []