Fix memory leak when percolating with nested documents

The percolator uses non segment reader impl (MemoryIndexReader), this causes associated cache entries not automatically be cleared when the reader closes and that is why the percolator removes the cache entries manually (filter cache, field data) 

However when percolating a document with nested objects a multi reader is used that wraps a MemoryIndexReader for each nested object. Cache entries use the leaves as key in filter / field data cache, but the percolator clear using the top level multi reader. This causes cache entries never to be evicted and resulting in OOM.

The memory is fixed by the following changes:
* Not allowing caching for non segment reader implementations.
* The percolator never cache anything that associated with the in-memory index where document being percolated resides in.
Make, sense I will do that then in 1.2 branch only.


On 26 June 2014 14:09, Simon Willnauer <notifications@github.com> wrote:

> In
> src/main/java/org/elasticsearch/index/cache/filter/weighted/WeightedFilterCache.java:
>
> > @@ -157,12 +165,11 @@ public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws
> >              DocIdSet cacheValue = innerCache.getIfPresent(cacheKey);
> >              if (cacheValue == null) {
> >                  if (!cache.seenReaders.containsKey(context.reader().getCoreCacheKey())) {
> > -                    Boolean previous = cache.seenReaders.putIfAbsent(context.reader().getCoreCacheKey(), Boolean.TRUE);
> > +                    SegmentReader segmentReader = SegmentReaderUtils.segmentReader(context.reader());
>
> yeah but then please fix this in 1.2.x
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/elasticsearch/elasticsearch/pull/6578/files#r14236611>
> .
>



-- 
Met vriendelijke groet,

Martijn van Groningen