ARTEMIS-3324 JournalFilesRepository running out of open files while compacting

This commit is contained in:
Clebert Suconic 2021-06-01 11:50:27 -04:00 committed by clebertsuconic
parent 7ce9030e9f
commit 24c6d904b9
3 changed files with 25 additions and 9 deletions

View File

@ -96,13 +96,11 @@ public class JournalFilesRepository {
@Override
public void run() {
// if there's already an opened file there is no need to push a new one
if (openedFiles.isEmpty()) {
try {
pushOpenedFile();
} catch (Exception e) {
ActiveMQJournalLogger.LOGGER.errorPushingFile(e);
fileFactory.onIOError(e, "unable to open ", null);
}
try {
pushOpenedFile();
} catch (Exception e) {
ActiveMQJournalLogger.LOGGER.errorPushingFile(e);
fileFactory.onIOError(e, "unable to open ", null);
}
}
};
@ -504,8 +502,7 @@ public class JournalFilesRepository {
}
if (nextFile == null) {
logger.debug("Could not get a file in " + journalFileOpenTimeout + " seconds, it will retry directly, without an executor");
ActiveMQJournalLogger.LOGGER.cantOpenFileTimeout(journalFileOpenTimeout);
try {
nextFile = takeFile(true, true, true, false);
} catch (Exception e) {

View File

@ -284,4 +284,8 @@ public interface ActiveMQJournalLogger extends BasicLogger {
@LogMessage(level = Logger.Level.WARN)
@Message(id = 144008, value = "*******************************************************************************************************************************\nFile {0}: was moved under attic, please review it and remove it.\n*******************************************************************************************************************************", format = Message.Format.MESSAGE_FORMAT)
void movingFileToAttic(String fileName);
@LogMessage(level = Logger.Level.WARN)
@Message(id = 144009, value = "Could not get a file in {0} seconds, System will retry the open but you may see increased latency in your system", format = Message.Format.MESSAGE_FORMAT)
void cantOpenFileTimeout(long timeout);
}

View File

@ -38,6 +38,7 @@ import org.apache.activemq.artemis.core.journal.TestableJournal;
import org.apache.activemq.artemis.core.journal.impl.JournalFile;
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
import org.apache.activemq.artemis.core.journal.impl.JournalReaderCallback;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.ReusableLatch;
import org.apache.activemq.artemis.utils.collections.SparseArrayLinkedList;
@ -48,6 +49,20 @@ import org.junit.Before;
public abstract class JournalImplTestBase extends ActiveMQTestBase {
@Before
public void startLogger() {
AssertionLoggerHandler.startCapture();
}
@After
public void stopLogger() {
try {
Assert.assertFalse(AssertionLoggerHandler.findText("AMQ144009"));
} finally {
AssertionLoggerHandler.stopCapture();
}
}
private static final Logger log = Logger.getLogger(JournalImplTestBase.class);
protected List<RecordInfo> records = new LinkedList<>();