fix refresh logic after the change to not do it under write lock

This commit is contained in:
kimchy 2011-05-19 00:36:07 +03:00
parent 23fad52498
commit ed8d6bbcd3
2 changed files with 9 additions and 7 deletions

View File

@ -581,7 +581,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
@Override public Searcher searcher() throws EngineException {
AcquirableResource<ReaderSearcherHolder> holder;
for (; ;) {
for (; ; ) {
holder = this.nrtResource;
if (holder.acquire()) {
break;
@ -709,8 +709,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
// we need to refresh in order to clear older version values
long time = threadPool.estimatedTimeInMillis(); // mark time here, before we refresh, and then delete all older values
refresh(new Refresh(true).force(true));
if (indexingSearcher.get() != null) {
indexingSearcher.get().release();
Searcher searcher = indexingSearcher.get();
if (searcher != null) {
indexingSearcher.set(null);
}
for (Map.Entry<String, VersionValue> entry : versionMap.entrySet()) {
@ -732,6 +732,9 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
}
}
}
if (searcher != null) {
searcher.release();
}
} finally {
flushing.set(false);
}

View File

@ -496,15 +496,14 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
if (withFlush) {
engine.flush(new Engine.Flush());
}
// clear unreferenced files
translog.clearUnreferenced();
engine.refresh(new Engine.Refresh(true));
synchronized (mutex) {
logger.debug("state: [{}]->[{}], reason [post recovery]", state, IndexShardState.STARTED);
state = IndexShardState.STARTED;
}
startScheduledTasksIfNeeded();
engine.refresh(new Engine.Refresh(true));
// clear unreferenced files
translog.clearUnreferenced();
indicesLifecycle.afterIndexShardStarted(this);
}