-
Notifications
You must be signed in to change notification settings - Fork 781
Fix cached task after abort #6903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jorgee
wants to merge
4
commits into
master
Choose a base branch
from
6884-fix-retries-with-abort
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| set -e | ||
|
|
||
| # | ||
| # run with abort | ||
| # | ||
| echo '' | ||
| timeout --signal=INT 3 $NXF_RUN | tee stdout || true | ||
|
|
||
| [[ `< .nextflow.log grep -c 'Submitted process > SMALL_SLEEP_RETRY'` == 1 ]] || false | ||
|
|
||
|
|
||
| # | ||
| # RESUME mode with fail and abort | ||
| # | ||
| echo '' | ||
| timeout --signal=INT 9 $NXF_RUN -resume | tee stdout || true | ||
|
|
||
| [[ `< .nextflow.log grep -c 'Submitted process > SMALL_SLEEP_RETRY'` == 1 ]] || false | ||
| [[ `< .nextflow.log grep -c 'Re-submitted process > SMALL_SLEEP_RETRY'` == 1 ]] || false | ||
| # | ||
| # RESUME mode with completed and abort | ||
| # | ||
| echo '' | ||
| timeout --signal=INT 9 $NXF_RUN -resume | tee stdout || true | ||
|
|
||
| [[ `< .nextflow.log grep -c 'Submitted process > SMALL_SLEEP_RETRY'` == 1 ]] || false | ||
|
|
||
| # | ||
| # RESUME mode with cached and finish | ||
| # | ||
| echo '' | ||
| $NXF_RUN -resume | tee stdout | ||
|
|
||
| [[ `< .nextflow.log grep -c 'Cached process > SMALL_SLEEP_RETRY'` == 1 ]] || false |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #!/usr/bin/env nextflow | ||
| /* | ||
| * Copyright 2013-2026, Seqera Labs | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| process LONG_SLEEP { | ||
| tag "long-sleep" | ||
|
|
||
| input: | ||
| val x | ||
|
|
||
| output: | ||
| stdout | ||
|
|
||
| script: | ||
| ''' | ||
| echo "LONG_SLEEP start" | ||
| sleep 30 | ||
| echo "LONG_SLEEP done" | ||
| ''' | ||
| } | ||
|
|
||
| process SMALL_SLEEP_RETRY { | ||
| tag "small-sleep-retry" | ||
|
|
||
| errorStrategy 'retry' | ||
| maxRetries 1 | ||
|
|
||
| input: | ||
| val x | ||
|
|
||
| output: | ||
| stdout | ||
|
|
||
| script: | ||
| """ | ||
| echo "SMALL_SLEEP_RETRY attempt: ${task.attempt}" | ||
| sleep 5 | ||
|
|
||
| if [[ ${task.attempt} -eq 1 ]]; then | ||
| echo "Failing first attempt on purpose" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Second attempt succeeded" | ||
| """ | ||
| } | ||
|
|
||
| workflow { | ||
| ch = Channel.of(1) | ||
| LONG_SLEEP(ch) | ||
| SMALL_SLEEP_RETRY(ch) | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is not currently required to fix the case of the issue.
However, when a task has been executed with previous failures but has not been completed, it is not cached, and it is re-executed. This execution is done with
task.attempt = 1, with this code it is re-exceuted withtask.attempt = failedCount +1.This case is happening in the added test. A process is defined to fail in the first attempt and succeed for the rest. So, it should execute twice in total. In the test, the execution is aborted after the first retry. Without this code, the task will be reexecuted again twice (first fails and second succeeds). With this code, the previous failed task will be counted as an attempt and then the task runs only once.
I am not sure if reexecuting with attempt =1 was intended or if it should be managed as in this code and update the attempts according to cached failures. @bentsherman @pditommaso what's your opinion about it?