|
|
@@ -1077,22 +1077,34 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Creates a new {@link IndexCommit} snapshot form the currently running engine. All resources referenced by this
|
|
|
+ * Creates a new {@link IndexCommit} snapshot from the currently running engine. All resources referenced by this
|
|
|
* commit won't be freed until the commit / snapshot is closed.
|
|
|
*
|
|
|
- * @param safeCommit <code>true</code> capture the most recent safe commit point; otherwise the most recent commit point.
|
|
|
* @param flushFirst <code>true</code> if the index should first be flushed to disk / a low level lucene commit should be executed
|
|
|
*/
|
|
|
- public Engine.IndexCommitRef acquireIndexCommit(boolean safeCommit, boolean flushFirst) throws EngineException {
|
|
|
- IndexShardState state = this.state; // one time volatile read
|
|
|
+ public Engine.IndexCommitRef acquireLastIndexCommit(boolean flushFirst) throws EngineException {
|
|
|
+ final IndexShardState state = this.state; // one time volatile read
|
|
|
// we allow snapshot on closed index shard, since we want to do one after we close the shard and before we close the engine
|
|
|
if (state == IndexShardState.STARTED || state == IndexShardState.RELOCATED || state == IndexShardState.CLOSED) {
|
|
|
- return getEngine().acquireIndexCommit(safeCommit, flushFirst);
|
|
|
+ return getEngine().acquireLastIndexCommit(flushFirst);
|
|
|
} else {
|
|
|
throw new IllegalIndexShardStateException(shardId, state, "snapshot is not allowed");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Snapshots the most recent safe index commit from the currently running engine.
|
|
|
+ * All index files referenced by this index commit won't be freed until the commit/snapshot is closed.
|
|
|
+ */
|
|
|
+ public Engine.IndexCommitRef acquireSafeIndexCommit() throws EngineException {
|
|
|
+ final IndexShardState state = this.state; // one time volatile read
|
|
|
+ // we allow snapshot on closed index shard, since we want to do one after we close the shard and before we close the engine
|
|
|
+ if (state == IndexShardState.STARTED || state == IndexShardState.RELOCATED || state == IndexShardState.CLOSED) {
|
|
|
+ return getEngine().acquireSafeIndexCommit();
|
|
|
+ } else {
|
|
|
+ throw new IllegalIndexShardStateException(shardId, state, "snapshot is not allowed");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* gets a {@link Store.MetadataSnapshot} for the current directory. This method is safe to call in all lifecycle of the index shard,
|
|
|
@@ -1121,7 +1133,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
|
|
|
return store.getMetadata(null, true);
|
|
|
}
|
|
|
}
|
|
|
- indexCommit = engine.acquireIndexCommit(false, false);
|
|
|
+ indexCommit = engine.acquireLastIndexCommit(false);
|
|
|
return store.getMetadata(indexCommit.getIndexCommit());
|
|
|
} finally {
|
|
|
store.decRef();
|