Skip to content

Commit a82b4ff

Browse files
authored
fix: fix a logic for non-retry on partially processed task (#871)
1 parent aa85c89 commit a82b4ff

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

server/internal/infprocessor/infprocessor.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,6 @@ func (p *P) enqueueAndProcessTask(
493493

494494
// Process the task results.
495495
for {
496-
var hasReceivedResult bool
497496
select {
498497
case <-ctx.Done():
499498
log.Error(ctx.Err(), "Task completed due to context cancel")
@@ -512,7 +511,9 @@ func (p *P) enqueueAndProcessTask(
512511
}
513512

514513
err = processResult(r.result)
515-
task.nextResultIndex++
514+
if err == nil {
515+
task.nextResultIndex++
516+
}
516517
}
517518

518519
if err != nil {
@@ -521,7 +522,7 @@ func (p *P) enqueueAndProcessTask(
521522
}
522523

523524
// Retry if possible. Do not retry once the task has received a result.
524-
if hasReceivedResult || !p.canRetry(task, err) {
525+
if task.nextResultIndex > 0 || !p.canRetry(task, err) {
525526
log.Error(err, "Failed to process the task")
526527
return err
527528
}
@@ -542,8 +543,6 @@ func (p *P) enqueueAndProcessTask(
542543
continue
543544
}
544545

545-
hasReceivedResult = true
546-
547546
// Check if the task is completed.
548547
completed, err := isTaskCompleted(task, r.result)
549548
if err != nil {

0 commit comments

Comments
 (0)