Fix deadlock in multi-level job dependency failures#141
Merged
Conversation
This commit fixes a deadlock issue that occurred when jobs with multi-level dependencies (3+ levels) failed. Problem: When a job at level 1 failed, jobs at level 2 would be marked as JobFailed. However, jobs at level 3+ that depended on level 2 jobs would remain in JobPending status indefinitely, causing a deadlock. Root Cause: The MarkJobsWithFailedDependencies() method only checked for dependencies with status JobCompleted && !results, but did not check for dependencies with status JobFailed. Solution: Modified scheduler.go:257 to also check for JobFailed status: - Before: if status[dep] == JobCompleted && !results[dep] - After: if status[dep] == JobFailed || (status[dep] == JobCompleted && !results[dep]) This allows failure status to propagate through all dependency levels. Changes: - scheduler.go: Fix dependency failure detection - scheduler_test.go: Add unit tests for multi-level dependency failures - examples/needs-literal.yml: Add 5-level dependency chain to verify fix Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
- Add proper error handling for scheduler.AddJob() calls in tests - Use t.Fatalf() to immediately fail tests if job addition fails Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Code Metrics Report
Details | | main (1b59337) | #141 (4923d7a) | +/- |
|---------------------|----------------|----------------|-------|
+ | Coverage | 48.2% | 48.5% | +0.3% |
| Files | 52 | 52 | 0 |
| Lines | 5244 | 5244 | 0 |
+ | Covered | 2530 | 2546 | +16 |
+ | Code to Test Ratio | 1:1.1 | 1:1.1 | +0.0 |
| Code | 10564 | 10564 | 0 |
+ | Test | 11856 | 11955 | +99 |
+ | Test Execution Time | 24s | 13s | -11s |Code coverage of files in pull request scope (76.5% → 90.9%)
Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a deadlock issue that occurred when jobs with multi-level dependencies (3+ levels) failed in sequence.
Problem
When running workflows with multi-level job dependencies where early jobs failed:
JobFailedJobPendingstatus indefinitelyExample scenario (testdata/verify-examples.yml):
Root Cause
The
MarkJobsWithFailedDependencies()method in scheduler.go only checked for dependencies with:This missed dependencies that were already marked as
JobFailed, preventing failure propagation beyond 2 levels.Solution
Modified scheduler.go:257 to also check for
JobFailedstatus:Now failure status correctly propagates through all dependency levels.
Test Plan
scheduler_test.gofor multi-level dependency failuresexamples/needs-literal.ymlwith 5-level dependency chaintestdata/verify-examples.ymlin docker context failure scenarioExample output (5-level chain):
All jobs complete immediately without deadlock.
🤖 Generated with Claude Code