Add methods to retry failed workflows and jobs across all steps and queues

This commit is contained in:
Achim Rohn
2026-04-08 15:41:22 +02:00
parent d4714c4f27
commit d4008e3655
2 changed files with 44 additions and 9 deletions
+22 -3
View File
@@ -575,9 +575,8 @@ func (q *GeneralQueue) IncrementTries(ctx context.Context, jobID int, currentTri
return nil
}
// ResumeWorkflow resets jobs for a specific workflow in this queue so they can be processed again.
// - All jobs with status InProgress are set back to Pending.
// - All jobs with status Failed are set back to Pending and their NumberOfTries is reset to 0.
// ResumeWorkflow resumes a specific workflow's execution in this queue by
// setting all InProgress jobs back to Pending, allowing them to be picked up again.
// After resetting, if the queue is marked running, it will be started.
func (q *GeneralQueue) ResumeWorkflow(ctx context.Context, workflowId string) error {
// Reset in-progress jobs back to pending for the specific workflow
@@ -597,6 +596,26 @@ func (q *GeneralQueue) ResumeWorkflow(ctx context.Context, workflowId string) er
Debug("Reset ", inProgressCount, " in_progress jobs to pending for ", q.Name, " queue (workflow:", workflowId, ")")
}
// Start the queue again if it is configured as running
if isRunning, err := q.IsRunning(ctx); err != nil {
Error("Failed to check ", q.Name, " queue state:", err)
} else if isRunning {
Debug("restarting ", q.Name, " queue")
if err := q.Start(ctx); err != nil {
Error("Failed to restart ", q.Name, " queue:", err)
return err
}
Debug(q.Name, " queue auto-started")
} else {
Debug(q.Name, " queue not running")
}
return nil
}
// RetryFailedWorkflow retries failed jobs for a specific workflow in this queue by
// setting all Failed jobs back to Pending and resetting their NumberOfTries to 0.
// After resetting, if the queue is marked running, it will be started.
func (q *GeneralQueue) RetryFailedWorkflow(ctx context.Context, workflowId string) error {
// Reset failed jobs back to pending and reset their try counter for the specific workflow
failedCount, err := q.client.GeneralQueue.Update().
Where(