diff --git a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalLuceneIndex.java b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalLuceneIndex.java index f8b6ca5..df4ffa7 100644 --- a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalLuceneIndex.java +++ b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalLuceneIndex.java @@ -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(); }