fix(store): a restart re-queues a running task at its interrupted step and parks it after 3 restarts (#1841)
This commit is contained in:
11 files changed
+338
-62
No files matched your search
@@ -188,8 +188,19 @@ DELETE FROM tasks
|
||||
WHERE status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed')
|
||||
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
||||
|
||||
-- name: RecoverStaleTasks :execrows
|
||||
UPDATE tasks SET status = 'queued', updated_at = now() WHERE status = 'running';
|
||||
-- name: RequeueRecoveredTask :execrows
|
||||
-- The restart's re-queue of a task it found running, resuming where the
|
||||
-- interrupted attempt stood. The conversation is kept only for the step the
|
||||
-- row already resumed at.
|
||||
UPDATE tasks SET status = 'queued', restart_requeues = restart_requeues + 1,
|
||||
retry_mode = @retry_mode::text, resume_results = @resume_results::jsonb,
|
||||
resume_history = CASE WHEN resume_from = @resume_from::text THEN resume_history ELSE 'null' END,
|
||||
resume_from = @resume_from::text, updated_at = now()
|
||||
WHERE id = @id AND status = 'running';
|
||||
|
||||
-- name: ParkRecoveredTask :execrows
|
||||
UPDATE tasks SET status = 'parked', park_reason = @park_reason, park_class = 'needs_decision', updated_at = now()
|
||||
WHERE id = @id AND status = 'running';
|
||||
|
||||
-- name: EnqueueIssue :execrows
|
||||
-- The org is derived from the identity at the one place a task row is
|
||||
@@ -265,11 +276,11 @@ WHERE id = $1 AND status = 'pr_open';
|
||||
-- name: RequeueTask :execrows
|
||||
UPDATE tasks SET status = 'queued',
|
||||
workflow = CASE WHEN @workflow::text = '' THEN workflow ELSE @workflow::text END,
|
||||
park_reason = '', park_class = 'needs_decision', updated_at = now()
|
||||
park_reason = '', park_class = 'needs_decision', restart_requeues = 0, updated_at = now()
|
||||
WHERE id = @id AND status = @from_status;
|
||||
|
||||
-- name: RetryTask :execrows
|
||||
UPDATE tasks SET status = 'queued', retry_count = retry_count + 1,
|
||||
UPDATE tasks SET status = 'queued', retry_count = retry_count + 1, restart_requeues = 0,
|
||||
workflow = CASE WHEN @workflow::text = '' THEN workflow ELSE @workflow::text END,
|
||||
retry_mode = @retry_mode::text,
|
||||
resume_from = @resume_from::text, resume_results = @resume_results::jsonb, resume_history = 'null',
|
||||
|
||||
Reference in new issue
Block a user