Add methods to retry failed workflows and jobs across all steps and queues
This commit is contained in:
+22
-3
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user