From 49cf4062a9d7e8669a3b9fe1a2a7020506035c54 Mon Sep 17 00:00:00 2001 From: Albert Louis Rossi Date: Fri, 8 Sep 2023 08:54:16 -0500 Subject: [PATCH] dcache-bulk: handle InterruptedException in DirListTask Motivation: https://rb.dcache.org/r/14041/ `master@2acfaf8d145a2f662a604865ba92f915e39ffa9d` introduced multithreaded concurrent listing using a `DirListTask`. During cancellation, this stack trace may occur repeatedly: ``` pool-13-thread-24] [] Uncaught exception in thread pool-13-thread-24java.lang.InterruptedException: null at org.dcache.services.bulk.job.AbstractRequestContainerJob.checkForRequestCancellation(AbstractRequestContainerJob.java:396) at org.dcache.services.bulk.job.RequestContainerJob.perform(RequestContainerJob.java:257) at org.dcache.services.bulk.job.RequestContainerJob.handleFileTarget(RequestContainerJob.java:191) at org.dcache.services.bulk.job.AbstractRequestContainerJob$1.doList(AbstractRequestContainerJob.java:442) at org.dcache.services.bulk.job.AbstractRequestContainerJob$DirListTask.run(AbstractRequestContainerJob.java:146) at org.dcache.util.BoundedExecutor$Worker.run(BoundedExecutor.java:247) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) ``` This is due to the fact that the InterruptedException generated by the cancellation is not handled separately in the wrapped `DirListTask`. Modification: Treat the InterruptedException as a special case, as it should be. Result: No more cluttering of the log file when jobs with ongoing listing activity are cancelled. Target: master Patch: https://rb.dcache.org/r/14091/ Requires-notes: no (unreleased changes) Acked-by: Tigran --- .../dcache/services/bulk/job/AbstractRequestContainerJob.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/job/AbstractRequestContainerJob.java b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/job/AbstractRequestContainerJob.java index 59f8244b1c8..b3b7e778c9e 100644 --- a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/job/AbstractRequestContainerJob.java +++ b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/job/AbstractRequestContainerJob.java @@ -144,6 +144,10 @@ abstract class DirListTask implements Runnable { public void run() { try { doList(); + } catch (InterruptedException e) { + containerState = ContainerState.STOP; + target.setErrorObject(e); + update(CANCELLED); } catch (Throwable e) { errorHandler.accept(e); Throwables.throwIfUnchecked(e);