From 815917fbf8411eaceb3b4042031fa82d20d5b52e Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Fri, 5 Apr 2013 23:27:03 +0200 Subject: [PATCH] confusing code..., but we can't release the searcher in a get result case we need that searcher later on..., need to think of how to simplify that..., added a comment for now --- .../org/elasticsearch/index/engine/robin/RobinEngine.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java b/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java index 0c9207acfe3..694ef31a35d 100644 --- a/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java +++ b/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java @@ -333,15 +333,17 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine { AtomicReaderContext readerContext = readers.get(i); UidField.DocIdAndVersion docIdAndVersion = UidField.loadDocIdAndVersion(readerContext, get.uid()); if (docIdAndVersion != null && docIdAndVersion.docId != Lucene.NO_DOC) { + // note, we don't release the searcher here, since it will be released as part of the external + // API usage, since it still needs it to load data... return new GetResult(searcher, docIdAndVersion); } } } catch (Exception e) { + searcher.release(); //TODO: A better exception goes here throw new EngineException(shardId(), "failed to load document", e); - } finally { - searcher.release(); } + searcher.release(); return GetResult.NOT_EXISTS; } finally { rwl.readLock().unlock();