You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to close the Lucene IndexWriter when the library is closed or when JabRef shuts down. The index should be closed in the background because writing commits to the disk takes time.
Which method should be used for submitting background tasks? All Lucene indexing runs in the background using org.jabref.gui.util.BackgroundTask, but for closing the index, I used org.jabref.logic.util.HeadlessExecutorService.
If I use org.jabref.logic.util.HeadlessExecutorService#INSTANCE.execute(), it works without any interruptions, and JabRef waits until the closing task is finished:
LOGGER.error("Error while closing linked files index", e);
}
});
}
If I use org.jabref.gui.util.BackgroundTask#executeWith to close the index, the task gets interrupted when it takes some time.
BackgroundTask.wrap(() -> {
try {
LOGGER.debug("Closing linked files index");
searcherManager.close();
optimizeIndex();
indexWriter.close();
indexDirectory.close();
LOGGER.debug("Linked files index closed");
if (databaseContext.getFulltextIndexPath().getFileName().toString().equals("unsaved")) {
LOGGER.debug("Deleting unsaved index directory");
FileUtils.deleteDirectory(indexDirectoryPath.toFile());
}
} catch (IOExceptione) {
LOGGER.error("Error while closing linked files index", e);
}
}).executeWith(taskExecutor);
}
Stack trace
[pool-2-thread-3] org.jabref.logic.search.indexing.DefaultLinkedFilesIndexer.optimizeIndex()
WARN: Could not force merge segments.: java.nio.channels.ClosedChannelException
at java.base/sun.nio.ch.FileLockImpl.release(FileLockImpl.java:58)
at java.base/java.nio.channels.FileLock.close(FileLock.java:336)
at [email protected]/org.apache.lucene.store.NativeFSLockFactory$NativeFSLock.close(NativeFSLockFactory.java:195)
at [email protected]/org.apache.lucene.util.IOUtils.close(IOUtils.java:85)
at [email protected]/org.apache.lucene.util.IOUtils.close(IOUtils.java:72)
at [email protected]/org.apache.lucene.index.IndexWriter.rollbackInternalNoCommit(IndexWriter.java:2559)
at [email protected]/org.apache.lucene.index.IndexWriter.rollbackInternal(IndexWriter.java:2464)
at [email protected]/org.apache.lucene.index.IndexWriter.maybeCloseOnTragicEvent(IndexWriter.java:5774)
at [email protected]/org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:4321)
at [email protected]/org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:4255)
at [email protected]/org.apache.lucene.index.IndexWriter.forceMerge(IndexWriter.java:2128)
at [email protected]/org.jabref.logic.search.indexing.DefaultLinkedFilesIndexer.optimizeIndex(DefaultLinkedFilesIndexer.java:332)
at [email protected]/org.jabref.logic.search.indexing.DefaultLinkedFilesIndexer.lambda$close$5(DefaultLinkedFilesIndexer.java:344)
at [email protected]/org.jabref.gui.util.BackgroundTask$2.call(BackgroundTask.java:91)
at [email protected]/org.jabref.gui.util.BackgroundTask$2.call(BackgroundTask.java:88)
at [email protected]/org.jabref.gui.util.UiTaskExecutor$1.call(UiTaskExecutor.java:173)
at [email protected]/javafx.concurrent.Task$TaskCallable.call(Task.java:1399)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
I want to close the Lucene IndexWriter when the library is closed or when JabRef shuts down. The index should be closed in the background because writing commits to the disk takes time.
And it is OK to not show any progress in the UI?
As far as I understand the PR JabRef#11385, there was some renaming to distinguish between UI and nonUI (called "headless").
As far as I understand your options and pros and cons, I think, calling HeadlessExecutorService is the right choice? We accept that no progress is shown in the UI. Nevertheless, there should be a LOGGER.info be called at the start and at the end. Sometimes, JabRef hangs during exiting (refs JabRef#11430) and it should be "easy" to trace which component hangs.
I want to close the Lucene
IndexWriter
when the library is closed or when JabRef shuts down. The index should be closed in the background because writing commits to the disk takes time.Which method should be used for submitting background tasks? All Lucene indexing runs in the background using
org.jabref.gui.util.BackgroundTask
, but for closing the index, I usedorg.jabref.logic.util.HeadlessExecutorService
.org.jabref.logic.util.HeadlessExecutorService#INSTANCE.execute()
, it works without any interruptions, and JabRef waits until the closing task is finished:jabref/src/main/java/org/jabref/logic/search/indexing/DefaultLinkedFilesIndexer.java
Lines 339 to 357 in ab5388f
org.jabref.gui.util.BackgroundTask#executeWith
to close the index, the task gets interrupted when it takes some time.Stack trace
@koppor, please take a look when you are available. Refs: https://github.com/JabRef/jabref-issue-melting-pot/issues/443
The text was updated successfully, but these errors were encountered: