Skip to content

Commit

Permalink
feat: do not move requests to pending if the batch failed when using …
Browse files Browse the repository at this point in the history
…queue batches (#1181)
  • Loading branch information
stephhuynh18 authored Dec 14, 2023
1 parent cff4bf8 commit 74b51f0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/services/anchor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 74b51f0

Please sign in to comment.