diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java index f641aecd0b..9d3a824eb1 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java @@ -18,6 +18,8 @@ package org.apache.activemq.artemis.core.io.aio; import java.io.File; import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; import java.nio.ByteBuffer; import java.util.PriorityQueue; import java.util.concurrent.Executor; @@ -100,16 +102,34 @@ public class AIOSequentialFile extends AbstractSequentialFile { super.close(); - if (!pendingCallbacks.await(10, TimeUnit.SECONDS)) { - factory.onIOError(new IOException("Timeout on close"), "Timeout on close", this); + final String fileName = this.getFileName(); + try { + int waitCount = 0; + while (!pendingCallbacks.await(10, TimeUnit.SECONDS)) { + waitCount++; + if (waitCount == 1) { + final ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true); + for (ThreadInfo threadInfo : threads) { + ActiveMQJournalLogger.LOGGER.warn(threadInfo.toString()); + } + factory.onIOError(new IOException("Timeout on close"), "Timeout on close", this); + } + ActiveMQJournalLogger.LOGGER.warn("waiting pending callbacks on " + fileName + " from " + (waitCount * 10) + " seconds!"); + } + } catch (InterruptedException e) { + ActiveMQJournalLogger.LOGGER.warn("interrupted while waiting pending callbacks on " + fileName, e); + throw e; + } finally { + + opened = false; + + timedBuffer = null; + + aioFile.close(); + + aioFile = null; + } - - opened = false; - - timedBuffer = null; - - aioFile.close(); - aioFile = null; } @Override