fix: cancellations, failures, and retries edge case (#1377)

This commit is contained in:
abelanger5
2025-03-20 17:27:50 -04:00
committed by GitHub
parent 3d3cabfbdd
commit 2333090751
2 changed files with 20 additions and 0 deletions

View File

@@ -249,6 +249,11 @@ WITH input AS (
step_id
FROM
v1_task
-- only fail tasks which have a v1_task_runtime equivalent to the current retry count. otherwise,
-- a cancellation which deletes the v1_task_runtime might lead to a future failure event, which triggers
-- a retry.
JOIN
v1_task_runtime rt ON rt.task_id = v1_task.id AND rt.task_inserted_at = v1_task.inserted_at AND rt.retry_count = v1_task.retry_count
WHERE
(id, inserted_at) IN (SELECT task_id, task_inserted_at FROM input)
AND tenant_id = @tenantId::uuid
@@ -300,6 +305,11 @@ WITH input AS (
id
FROM
v1_task
-- only fail tasks which have a v1_task_runtime equivalent to the current retry count. otherwise,
-- a cancellation which deletes the v1_task_runtime might lead to a future failure event, which triggers
-- a retry.
JOIN
v1_task_runtime rt ON rt.task_id = v1_task.id AND rt.task_inserted_at = v1_task.inserted_at AND rt.retry_count = v1_task.retry_count
WHERE
(id, inserted_at) IN (SELECT task_id, task_inserted_at FROM input)
AND tenant_id = @tenantId::uuid

View File

@@ -91,6 +91,11 @@ WITH input AS (
step_id
FROM
v1_task
-- only fail tasks which have a v1_task_runtime equivalent to the current retry count. otherwise,
-- a cancellation which deletes the v1_task_runtime might lead to a future failure event, which triggers
-- a retry.
JOIN
v1_task_runtime rt ON rt.task_id = v1_task.id AND rt.task_inserted_at = v1_task.inserted_at AND rt.retry_count = v1_task.retry_count
WHERE
(id, inserted_at) IN (SELECT task_id, task_inserted_at FROM input)
AND tenant_id = $3::uuid
@@ -185,6 +190,11 @@ WITH input AS (
id
FROM
v1_task
-- only fail tasks which have a v1_task_runtime equivalent to the current retry count. otherwise,
-- a cancellation which deletes the v1_task_runtime might lead to a future failure event, which triggers
-- a retry.
JOIN
v1_task_runtime rt ON rt.task_id = v1_task.id AND rt.task_inserted_at = v1_task.inserted_at AND rt.retry_count = v1_task.retry_count
WHERE
(id, inserted_at) IN (SELECT task_id, task_inserted_at FROM input)
AND tenant_id = $4::uuid