index.shard.check_on_startup set to fix: throw failure only if we are not fixing the index
This commit is contained in:
parent
19292bddc0
commit
3893417c44
|
@ -30,6 +30,7 @@ import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||||
import org.elasticsearch.ElasticSearchIllegalStateException;
|
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
|
import org.elasticsearch.common.Booleans;
|
||||||
import org.elasticsearch.common.BytesHolder;
|
import org.elasticsearch.common.BytesHolder;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
|
@ -265,7 +266,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
if (state == IndexShardState.RELOCATED) {
|
if (state == IndexShardState.RELOCATED) {
|
||||||
throw new IndexShardRelocatedException(shardId);
|
throw new IndexShardRelocatedException(shardId);
|
||||||
}
|
}
|
||||||
if (!"false".equalsIgnoreCase(checkIndexOnStartup)) {
|
if (Booleans.parseBoolean(checkIndexOnStartup, false)) {
|
||||||
checkIndex(true);
|
checkIndex(true);
|
||||||
}
|
}
|
||||||
engine.start();
|
engine.start();
|
||||||
|
@ -569,7 +570,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
throw new IndexShardNotRecoveringException(shardId, state);
|
throw new IndexShardNotRecoveringException(shardId, state);
|
||||||
}
|
}
|
||||||
// also check here, before we apply the translog
|
// also check here, before we apply the translog
|
||||||
if (!"false".equalsIgnoreCase(checkIndexOnStartup)) {
|
if (Booleans.parseBoolean(checkIndexOnStartup, false)) {
|
||||||
checkIndex(true);
|
checkIndex(true);
|
||||||
}
|
}
|
||||||
// we disable deletes since we allow for operations to be executed against the shard while recovering
|
// we disable deletes since we allow for operations to be executed against the shard while recovering
|
||||||
|
@ -858,9 +859,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.warn("check index [failure]\n{}", new String(os.underlyingBytes(), 0, os.size()));
|
logger.warn("check index [failure]\n{}", new String(os.underlyingBytes(), 0, os.size()));
|
||||||
if (throwException) {
|
|
||||||
throw new IndexShardException(shardId, "index check failure");
|
|
||||||
}
|
|
||||||
if ("fix".equalsIgnoreCase(checkIndexOnStartup)) {
|
if ("fix".equalsIgnoreCase(checkIndexOnStartup)) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("fixing index, writing new segments file ...");
|
logger.debug("fixing index, writing new segments file ...");
|
||||||
|
@ -869,6 +867,11 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("index fixed, wrote new segments file \"{}\"", status.segmentsFileName);
|
logger.debug("index fixed, wrote new segments file \"{}\"", status.segmentsFileName);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// only throw a failure if we are not going to fix the index
|
||||||
|
if (throwException) {
|
||||||
|
throw new IndexShardException(shardId, "index check failure");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|
Loading…
Reference in New Issue