mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
Merge pull request #11697 from jpountz/fix/synchronous_fielddata_removal
Reclaim memory from fielddata synchronously when an explicit clear is performed.
This commit is contained in:
commit
891689ed1e
@ -35,7 +35,6 @@ import org.elasticsearch.index.fielddata.AtomicFieldData;
|
|||||||
import org.elasticsearch.index.fielddata.FieldDataType;
|
import org.elasticsearch.index.fielddata.FieldDataType;
|
||||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||||
import org.elasticsearch.index.mapper.FieldMapper;
|
|
||||||
import org.elasticsearch.index.IndexService;
|
import org.elasticsearch.index.IndexService;
|
||||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
@ -222,15 +221,22 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL
|
|||||||
@Override
|
@Override
|
||||||
public void onClose(Object coreKey) {
|
public void onClose(Object coreKey) {
|
||||||
cache.invalidate(new Key(this, coreKey));
|
cache.invalidate(new Key(this, coreKey));
|
||||||
|
// don't call cache.cleanUp here as it would have bad performance implications
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose(IndexReader reader) {
|
public void onClose(IndexReader reader) {
|
||||||
cache.invalidate(new Key(this, reader.getCoreCacheKey()));
|
cache.invalidate(new Key(this, reader.getCoreCacheKey()));
|
||||||
|
// don't call cache.cleanUp here as it would have bad performance implications
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
for (Key key : cache.asMap().keySet()) {
|
||||||
|
if (key.indexCache.index.equals(index)) {
|
||||||
|
cache.invalidate(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Note that cache invalidation in Guava does not immediately remove
|
// Note that cache invalidation in Guava does not immediately remove
|
||||||
// values from the cache. In the case of a cache with a rare write or
|
// values from the cache. In the case of a cache with a rare write or
|
||||||
// read rate, it's possible for values to persist longer than desired.
|
// read rate, it's possible for values to persist longer than desired.
|
||||||
@ -238,11 +244,11 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL
|
|||||||
// Note this is intended by the Guava developers, see:
|
// Note this is intended by the Guava developers, see:
|
||||||
// https://code.google.com/p/guava-libraries/wiki/CachesExplained#Eviction
|
// https://code.google.com/p/guava-libraries/wiki/CachesExplained#Eviction
|
||||||
// (the "When Does Cleanup Happen" section)
|
// (the "When Does Cleanup Happen" section)
|
||||||
for (Key key : cache.asMap().keySet()) {
|
|
||||||
if (key.indexCache.index.equals(index)) {
|
// We call it explicitly here since it should be a "rare" operation, and
|
||||||
cache.invalidate(key);
|
// if a user runs it he probably wants to see memory returned as soon as
|
||||||
}
|
// possible
|
||||||
}
|
cache.cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -254,11 +260,16 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// we call cleanUp() because this is a manual operation, should happen
|
||||||
|
// rarely and probably means the user wants to see memory returned as
|
||||||
|
// soon as possible
|
||||||
|
cache.cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear(Object coreCacheKey) {
|
public void clear(Object coreCacheKey) {
|
||||||
cache.invalidate(new Key(this, coreCacheKey));
|
cache.invalidate(new Key(this, coreCacheKey));
|
||||||
|
// don't call cache.cleanUp here as it would have bad performance implications
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user