From 656e58ec40fbb335d35fc794090df248897caa64 Mon Sep 17 00:00:00 2001 From: Andrew Prudhomme Date: Thu, 7 Mar 2024 19:51:23 -0800 Subject: [PATCH] Close old reference manager when using FilteringSegmentInfosSearcherManager --- .../yelp/nrtsearch/server/luceneserver/NRTReplicaNode.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/yelp/nrtsearch/server/luceneserver/NRTReplicaNode.java b/src/main/java/com/yelp/nrtsearch/server/luceneserver/NRTReplicaNode.java index ee1f6f9df..d3a9f8f0a 100644 --- a/src/main/java/com/yelp/nrtsearch/server/luceneserver/NRTReplicaNode.java +++ b/src/main/java/com/yelp/nrtsearch/server/luceneserver/NRTReplicaNode.java @@ -39,6 +39,8 @@ import org.apache.lucene.replicator.nrt.NodeCommunicationException; import org.apache.lucene.replicator.nrt.ReplicaDeleterManager; import org.apache.lucene.replicator.nrt.ReplicaNode; +import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.ReferenceManager; import org.apache.lucene.search.SearcherFactory; import org.apache.lucene.store.Directory; import org.slf4j.Logger; @@ -121,7 +123,9 @@ public synchronized void start(long primaryGen) throws IOException { // Swap in a SearcherManager that filters incompatible segment readers during refresh. // Updating the reference is not thread safe, but since this happens under the object lock // and before the shard has stared, nothing should access the manager before the swap. + ReferenceManager oldMgr = mgr; mgr = new FilteringSegmentInfosSearcherManager(getDirectory(), this, mgr, searcherFactory); + oldMgr.close(); } }