ARTEMIS-3084 Issue a warning instead of blocking forever in case of not completing closes

This commit is contained in:
Clebert Suconic 2021-01-29 12:42:27 -05:00
parent 7ce5315d7a
commit b05bea7db9
2 changed files with 15 additions and 7 deletions

View File

@ -21,6 +21,7 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.PriorityQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.activemq.artemis.api.core.ActiveMQException;
@ -134,10 +135,14 @@ public class AIOSequentialFile extends AbstractSequentialFile {
@Override
public void waitNotPending() {
try {
short retryPending = 0;
do {
pendingCallbacks.await();
pendingCallbacks.await(1, TimeUnit.SECONDS);
}
while(pendingClose && retryPending < 60);
if (pendingClose) {
AIOSequentialFileFactory.threadDump("File " + getFileName() + " still has pending IO before closing it");
}
while(pendingClose);
} catch (InterruptedException e) {
// nothing to be done here, other than log it and forward it
logger.warn(e.getMessage(), e);

View File

@ -304,11 +304,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
try {
// if we stop libaioContext before we finish this, we will never get confirmation on items previously sent
if (!pendingClose.await(1, TimeUnit.MINUTES)) {
ActiveMQJournalLogger.LOGGER.warn("Timeout on waiting for asynchronous close");
final ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
for (ThreadInfo threadInfo : threads) {
ActiveMQJournalLogger.LOGGER.warn(threadInfo.toString());
}
threadDump("Timeout on waiting for asynchronous close");
}
} catch (Throwable throwableToLog) {
logger.warn(throwableToLog.getMessage(), throwableToLog);
@ -333,6 +329,13 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
}
}
static void threadDump(String message) {
ActiveMQJournalLogger.LOGGER.warn(message);
final ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
for (ThreadInfo threadInfo : threads) {
ActiveMQJournalLogger.LOGGER.warn(threadInfo.toString());
}
}
/**
* The same callback is used for Runnable executor.