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
@@ -56,7 +56,8 @@ RETURNING id, name;
|
||||
-- The executions a crashed or replaced daemon left running, locked for the
|
||||
-- recovery transaction so the step sweep and the requeue cannot race a
|
||||
-- concurrent write. The row carries the identity the steps' events need.
|
||||
SELECT id, org_id, workspace_id, owner, repo, issue_number, workflow, attempt
|
||||
SELECT id, org_id, workspace_id, owner, repo, issue_number, workflow, attempt,
|
||||
restart_requeues, retry_mode, resume_from, resume_results
|
||||
FROM tasks WHERE status = 'running' FOR UPDATE;
|
||||
|
||||
-- name: InterruptAttemptSteps :many
|
||||
@@ -68,7 +69,7 @@ FROM tasks WHERE status = 'running' FOR UPDATE;
|
||||
UPDATE step_executions
|
||||
SET status = 'interrupted', finished_at = now()
|
||||
WHERE execution_id = $1 AND attempt = $2 AND status = 'running'
|
||||
RETURNING id, name;
|
||||
RETURNING id, name, depth, kind;
|
||||
|
||||
-- name: ListStepExecutions :many
|
||||
-- attempt = 0 lists every attempt of the execution, oldest first; the index
|
||||
@@ -89,6 +90,15 @@ SELECT id, called_execution_id FROM step_executions
|
||||
WHERE execution_id = $1 AND attempt = $2
|
||||
AND kind = 'call' AND status IN ('pending', 'running') AND called_execution_id <> 0;
|
||||
|
||||
-- name: PriorStageResults :one
|
||||
-- What the attempt's last finished root stage before the given step recorded,
|
||||
-- the results a restart resumes that step with.
|
||||
SELECT results FROM step_executions
|
||||
WHERE execution_id = $1 AND attempt = $2 AND id < $3 AND depth = 0 AND kind = 'stage'
|
||||
AND status IN ('succeeded', 'failed', 'skipped') AND results IS NOT NULL
|
||||
ORDER BY id DESC
|
||||
LIMIT 1;
|
||||
|
||||
-- name: LatestStageResults :one
|
||||
-- The most recent finished run of a root stage, across attempts: a resumed
|
||||
-- attempt skips the stages before its resume point, so the last attempt that
|
||||
|
||||
Reference in new issue
Block a user