flush index caches more often and in read action (IDEA-182579)

This commit is contained in:
Maxim.Mossienko
2017-11-24 09:24:35 +01:00
parent f79971a377
commit 85a8bb730d
2 changed files with 8 additions and 9 deletions
@@ -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();
}
}
}
@@ -59,14 +59,13 @@ public abstract class MapReduceIndex<Key,Value, Input> 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);