@@ -1341,7 +1341,7 @@ impl<C> Server<C> {
13411341 JOIN workflow_status ws ON j_fail.workflow_id = ws.id AND r_fail.run_id = ws.run_id
13421342 WHERE jbb_fail.job_id = job.id
13431343 AND jbb_fail.workflow_id = ?
1344- AND j_fail.status IN (?, ?, ?, ? )
1344+ AND j_fail.status IN (?, ?, ?)
13451345 AND r_fail.return_code != 0
13461346 )
13471347 "# ,
@@ -1356,7 +1356,6 @@ impl<C> Server<C> {
13561356 canceled_status,
13571357 terminated_status,
13581358 workflow_id,
1359- completed_status,
13601359 failed_status,
13611360 canceled_status,
13621361 terminated_status
@@ -1453,8 +1452,8 @@ impl<C> Server<C> {
14531452 -- Base case: find jobs directly blocked by the completed job
14541453 SELECT
14551454 jbb.job_id,
1456- -- Cancel if: ANY dependency has non-zero return code AND cancel_on_blocking_job_failure = true
1457- -- We check ALL completed dependencies, not just the current one being processed
1455+ -- Cancel if: ANY dependency has failed (status is failed/canceled/terminated with non-zero return code)
1456+ -- AND cancel_on_blocking_job_failure = true. We check ALL failed dependencies, not just the current one.
14581457 CASE
14591458 WHEN j.cancel_on_blocking_job_failure != 0 AND EXISTS (
14601459 SELECT 1
@@ -1464,7 +1463,7 @@ impl<C> Server<C> {
14641463 JOIN workflow_status ws ON j_dep.workflow_id = ws.id AND r_dep.run_id = ws.run_id
14651464 WHERE jbb_dep.job_id = jbb.job_id
14661465 AND jbb_dep.workflow_id = ?
1467- AND j_dep.status IN (?, ?, ?, ? )
1466+ AND j_dep.status IN (?, ?, ?)
14681467 AND r_dep.return_code != 0
14691468 ) THEN 1
14701469 ELSE 0
@@ -1523,8 +1522,7 @@ impl<C> Server<C> {
15231522 "# ,
15241523 )
15251524 . bind ( workflow_id) // Base case: workflow_id for subquery
1526- . bind ( completed_status) // Base case: complete statuses for subquery
1527- . bind ( failed_status)
1525+ . bind ( failed_status) // Base case: failed statuses for subquery (not completed - status is source of truth)
15281526 . bind ( canceled_status)
15291527 . bind ( terminated_status)
15301528 . bind ( completed_job_id) // Base case: depends_on_job_id
0 commit comments