Permalink
Browse files

Closing a shard can cause a search/stats request that tries to acquir…

…e a handle to search while its closing to spin, closes #1772.
  • Loading branch information...
1 parent 8128c80 commit 7cc9108192addcd858c351ac9c4ce4977c3b1ef6 @kimchy kimchy committed Mar 9, 2012
Showing with 30 additions and 1 deletion.
  1. +30 −1 src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java
@@ -118,6 +118,9 @@
private volatile IndexWriter indexWriter;
+ // TODO LUCENE MONITOR 3.6: Replace this with SearchManager (3.6) once its out, it will not allow for forceClose, but maybe its a good thing...
+ // in any case, if we want to retain forceClose, we can call release multiple times...
+ // we won't need AcquirableResource any more as well, and close will not need to replace it with a closeable one
private volatile AcquirableResource<ReaderSearcherHolder> nrtResource;
private volatile boolean closed = false;
@@ -1228,6 +1231,8 @@ private void innerClose() {
try {
if (nrtResource != null) {
this.nrtResource.forceClose();
+ // replace the NRT resource with a closed one, meaning that
+ this.nrtResource = new ClosedNrtResource();
}
// no need to commit in this case!, we snapshot before we close the shard, so translog and all sync'ed
if (indexWriter != null) {
@@ -1368,7 +1373,7 @@ public void onRefreshSettings(Settings settings) {
return newAcquirableResource(new ReaderSearcherHolder(indexSearcher));
}
- private static class RobinSearchResult implements Searcher {
+ static class RobinSearchResult implements Searcher {
private final AcquirableResource<ReaderSearcherHolder> nrtHolder;
@@ -1422,4 +1427,28 @@ public boolean delete() {
return this.translogLocation;
}
}
+
+ class ClosedNrtResource implements AcquirableResource<ReaderSearcherHolder> {
+ @Override
+ public ReaderSearcherHolder resource() {
+ return null;
+ }
+
+ @Override
+ public boolean acquire() {
+ throw new EngineClosedException(shardId);
+ }
+
+ @Override
+ public void release() {
+ }
+
+ @Override
+ public void markForClose() {
+ }
+
+ @Override
+ public void forceClose() {
+ }
+ }
}

0 comments on commit 7cc9108

Please sign in to comment.