Skip to content

Commit ff6ab24

Browse files
committed
DecRef after hit creation
1 parent 4e3d55f commit ff6ab24

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichShardMultiSearchAction.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.cluster.service.ClusterService;
3232
import org.elasticsearch.common.Strings;
3333
import org.elasticsearch.common.breaker.CircuitBreaker;
34+
import org.elasticsearch.common.breaker.CircuitBreakingException;
3435
import org.elasticsearch.common.bytes.BytesReference;
3536
import org.elasticsearch.common.io.stream.BytesStreamOutput;
3637
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
@@ -262,11 +263,16 @@ protected MultiSearchResponse shardOperation(Request request, ShardId shardId) t
262263
return context.getFieldType(field);
263264
});
264265
final SearchHit hit = new SearchHit(scoreDoc.doc, visitor.id(), breaker);
265-
BytesReference source = visitor.source();
266-
hit.unfilteredSourceRef(source);
267-
breaker.addEstimateBytesAndMaybeBreak(source.length(), "enrich_msearch");
268-
hit.sourceRef(filterSource(fetchSourceContext, source));
269-
hits[j] = hit;
266+
try {
267+
BytesReference source = visitor.source();
268+
hit.unfilteredSourceRef(source);
269+
breaker.addEstimateBytesAndMaybeBreak(source.length(), "enrich_msearch");
270+
hit.sourceRef(filterSource(fetchSourceContext, source));
271+
hits[j] = hit;
272+
} catch (CircuitBreakingException e) {
273+
hit.decRef();
274+
throw e;
275+
}
270276
}
271277
items[i] = new MultiSearchResponse.Item(createSearchResponse(topDocs, hits), null);
272278
}

0 commit comments

Comments
 (0)