From 4c207c23c1afc7b8264322e2f634ad224e28c778 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Mon, 17 Jun 2024 12:42:53 +0200 Subject: [PATCH] Fix executions hangs on finalisation exception (#5070) Signed-off-by: Paolo Di Tommaso --- .../nextflow/processor/TaskPollingMonitor.groovy | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/TaskPollingMonitor.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/TaskPollingMonitor.groovy index a69042f659..29a820624e 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/TaskPollingMonitor.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/TaskPollingMonitor.groovy @@ -663,7 +663,7 @@ class TaskPollingMonitor implements TaskMonitor { // finalize the task asynchronously if( enableAsyncFinalizer ) { - finalizerPool.submit( ()-> finalizeTask(handler) ) + finalizerPool.submit( ()-> safeFinalizeTask(handler) ) } else { finalizeTask(handler) @@ -671,6 +671,16 @@ class TaskPollingMonitor implements TaskMonitor { } } + protected void safeFinalizeTask(TaskHandler handler) { + try { + finalizeTask(handler) + } + catch (Throwable t) { + log.error "Unexpected error while finalizing task '${handler.task.name}' - cause: ${t.message}" + session.abort(t) + } + } + protected void finalizeTask( TaskHandler handler ) { // finalize the task execution final fault = handler.task.processor.finalizeTask(handler.task)