Skip to content

Commit

Permalink
Fix Prevent false positive resumable task
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Sep 25, 2023
1 parent c4cd53c commit aae8771
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -767,13 +767,13 @@ class TaskProcessor {
Path resumeDir = null
boolean exists = false
try {
def entry = session.cache.getTaskEntry(hash, this)
final entry = session.cache.getTaskEntry(hash, this)
resumeDir = entry ? FileHelper.asPath(entry.trace.getWorkDir()) : null
if( resumeDir )
exists = resumeDir.exists()

log.trace "[${safeTaskName(task)}] Cacheable folder=${resumeDir?.toUriString()} -- exists=$exists; try=$tries; shouldTryCache=$shouldTryCache; entry=$entry"
def cached = shouldTryCache && exists && checkCachedOutput(task.clone(), resumeDir, hash, entry)
final cached = shouldTryCache && exists && entry.trace.isCompleted() && checkCachedOutput(task.clone(), resumeDir, hash, entry)
if( cached )
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ class TraceRecord implements Serializable {
store.status == 'CACHED'
}

boolean isCompleted() {
store.status == 'COMPLETED'
}

String getExecutorName() {
return executorName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package nextflow.trace

import groovy.json.JsonSlurper
import spock.lang.Specification
import spock.lang.Unroll
import test.TestHelper

/**
Expand Down Expand Up @@ -300,4 +301,36 @@ class TraceRecordTest extends Specification {
rec.env == 'aws_key=[secure]'
}

@Unroll
def 'should validate cached status' () {
given:
def rec = new TraceRecord([status:STATUS])

expect:
rec.isCached() == EXPECTED

where:
STATUS | EXPECTED
null | false
'NEW' | false
'ABORTED' | false
'CACHED' | true
}

@Unroll
def 'should validate completed status' () {
given:
def rec = new TraceRecord([status:STATUS])

expect:
rec.isCompleted() == EXPECTED

where:
STATUS | EXPECTED
null | false
'NEW' | false
'ABORTED' | false
'COMPLETED' | true
}

}

0 comments on commit aae8771

Please sign in to comment.