Skip to content
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

Fail the run if publish thread pool times out #5578

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions modules/nextflow/src/main/groovy/nextflow/Session.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import java.nio.file.Paths
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.TimeoutException

import com.google.common.hash.HashCode
import groovy.transform.CompileDynamic
Expand Down Expand Up @@ -689,8 +690,17 @@ class Session implements ISession {
try {
log.trace "Session > destroying"
// shutdown thread pools
finalizePoolManager?.shutdown(aborted)
publishPoolManager?.shutdown(aborted)
try {
finalizePoolManager?.shutdown(aborted)
publishPoolManager?.shutdown(aborted)
}
catch( TimeoutException e ) {
final ignoreErrors = config.navigate('workflow.output.ignoreErrors', false)
if( !ignoreErrors )
throw new AbortOperationException("Timed out while waiting to publish outputs")
else
log.warn e.message
}
// invoke shutdown callbacks
shutdown0()
log.trace "Session > after cleanup"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package nextflow.util
import java.util.concurrent.ExecutorService
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
Expand All @@ -45,10 +46,8 @@ class ThreadPoolHelper {
break

final delta = System.currentTimeMillis()-t0
if( delta > max ) {
log.warn(exitMsg)
break
}
if( delta > max )
throw new TimeoutException(exitMsg)

// log to console every 10 minutes (120 * 5 sec)
if( count % 120 == 0 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package nextflow.cloud.aws.batch

import java.nio.file.Path
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException

import com.amazonaws.services.batch.AWSBatch
import com.amazonaws.services.batch.model.AWSBatchException
Expand Down Expand Up @@ -320,7 +321,12 @@ class AwsBatchExecutor extends Executor implements ExtensionPoint, TaskArrayExec
reaper.shutdown()
final waitMsg = "[AWS BATCH] Waiting jobs reaper to complete (%d jobs to be terminated)"
final exitMsg = "[AWS BATCH] Exiting before jobs reaper thread pool complete -- Some jobs may not be terminated"
ThreadPoolHelper.await(reaper, Duration.of('60min'), waitMsg, exitMsg)
try {
ThreadPoolHelper.await(reaper, Duration.of('60min'), waitMsg, exitMsg)
}
catch( TimeoutException e ) {
log.warn e.message
}
}

@Override
Expand Down
14 changes: 0 additions & 14 deletions plugins/nf-amazon/src/main/nextflow/cloud/aws/nio/S3Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -660,18 +660,4 @@ public void uploadDirectory(File source, S3Path target) {
String getObjectKmsKeyId(String bucketName, String key) {
return getObjectMetadata(bucketName,key).getSSEAwsKmsKeyId();
}

protected void showdownTransferPool(boolean hard) {
log.debug("Initiating transfer manager shutdown (hard={})", hard);
if( hard ) {
transferPool.shutdownNow();
}
else {
// await pool completion
transferPool.shutdown();
final String waitMsg = "[AWS S3] Waiting files transfer to complete (%d files)";
final String exitMsg = "[AWS S3] Exiting before FileTransfer thread pool complete -- Some files maybe lost";
ThreadPoolHelper.await(transferPool, Duration.of("1h"), waitMsg, exitMsg);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -665,22 +665,4 @@ static synchronized ExecutorService getOrCreateExecutor(int maxThreads) {
return executorSingleton;
}

/**
* Shutdown the executor and clear the singleton
*/
static void shutdownExecutor(boolean hard) {
if( hard ) {
executorSingleton.shutdownNow();
}
else {
executorSingleton.shutdown();
log.trace("Uploader await completion");
final String waitMsg = "[AWS S3] Waiting stream uploader to complete (%d files)";
final String exitMsg = "[AWS S3] Exiting before stream uploader thread pool complete -- Some files maybe lost";
ThreadPoolHelper.await(executorSingleton, Duration.of("1h") ,waitMsg, exitMsg);
log.trace("Uploader shutdown completed");
executorSingleton = null;
}
}

}
Loading