Fix missing scheduling locks

This commit is contained in:
Andrea Cavalli 2020-12-31 12:05:04 +01:00
parent c676fa63a7
commit 84c5fb93a0

View File

@ -130,11 +130,14 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
}
private void registerScheduledFixedTask(Runnable task, Duration duration) {
scheduledTasksLifecycle.registerScheduledTask(scheduler.scheduleAtFixedRate(task,
duration.toMillis(),
duration.toMillis(),
TimeUnit.MILLISECONDS
));
scheduledTasksLifecycle.registerScheduledTask(scheduler.scheduleAtFixedRate(() -> {
scheduledTasksLifecycle.startScheduledTask();
try {
task.run();
} finally {
scheduledTasksLifecycle.endScheduledTask();
}
}, duration.toMillis(), duration.toMillis(), TimeUnit.MILLISECONDS));
}
@Override
@ -401,7 +404,9 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
private void scheduledQueryRefresh() {
try {
searcherManager.maybeRefreshBlocking();
if (!searcherManager.maybeRefresh()) {
// skipped refreshing because another thread is currently refreshing
}
} catch (IOException ex) {
ex.printStackTrace();
}