From 85a8bb730dc8f1d83c173112effae251e03a0f96 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Fri, 24 Nov 2017 09:20:31 +0100 Subject: [PATCH] flush index caches more often and in read action (IDEA-182579) --- .../intellij/util/indexing/FileBasedIndexImpl.java | 4 ++-- .../intellij/util/indexing/impl/MapReduceIndex.java | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index 67e56536b4ba..63d7caa34549 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -988,12 +988,12 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent, final MapReduceIndex index = (MapReduceIndex)state.getIndex(indexId); assert index != null; final MemoryIndexStorage memStorage = (MemoryIndexStorage)index.getStorage(); - index.getWriteLock().lock(); + index.getReadLock().lock(); try { memStorage.clearCaches(); } finally { - index.getWriteLock().unlock(); + index.getReadLock().unlock(); } } } diff --git a/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java b/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java index 3776a65dcf87..b0afa3cdab0b 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java +++ b/platform/util/src/com/intellij/util/indexing/impl/MapReduceIndex.java @@ -59,14 +59,13 @@ public abstract class MapReduceIndex implements InvertedIndex< @Override public void run() { try { - Lock writeLock = getWriteLock(); - if (writeLock.tryLock()) { - try { - myStorage.clearCaches(); - } finally { - writeLock.unlock(); - } + getReadLock().lock(); + try { + myStorage.clearCaches(); + } finally { + getReadLock().unlock(); } + flush(); } catch (Throwable e) { requestRebuild(e);