Unexpected failure to create a shard can lead to data loss if it has no replicas, closes #878.
This commit is contained in:
parent
3b07f77f3d
commit
1e5dc09848
|
@ -437,11 +437,22 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
|||
} catch (Exception e) {
|
||||
logger.warn("[{}][{}] failed to create shard", e, shardRouting.index(), shardRouting.id());
|
||||
try {
|
||||
indexService.cleanShard(shardId, "failed to create [" + ExceptionsHelper.detailedMessage(e) + "]");
|
||||
indexService.removeShard(shardId, "failed to create [" + ExceptionsHelper.detailedMessage(e) + "]");
|
||||
} catch (IndexShardMissingException e1) {
|
||||
// ignore
|
||||
} catch (Exception e1) {
|
||||
logger.warn("[{}][{}] failed to delete shard after failed creation", e1, shardRouting.index(), shardRouting.id());
|
||||
logger.warn("[{}][{}] failed to remove shard after failed creation", e1, shardRouting.index(), shardRouting.id());
|
||||
}
|
||||
shardStateAction.shardFailed(shardRouting, "Failed to create shard, message [" + detailedMessage(e) + "]");
|
||||
return;
|
||||
} catch (OutOfMemoryError e) {
|
||||
logger.warn("[{}][{}] failed to create shard", e, shardRouting.index(), shardRouting.id());
|
||||
try {
|
||||
indexService.removeShard(shardId, "failed to create [" + ExceptionsHelper.detailedMessage(e) + "]");
|
||||
} catch (IndexShardMissingException e1) {
|
||||
// ignore
|
||||
} catch (Exception e1) {
|
||||
logger.warn("[{}][{}] failed to remove shard after failed creation", e1, shardRouting.index(), shardRouting.id());
|
||||
}
|
||||
shardStateAction.shardFailed(shardRouting, "Failed to create shard, message [" + detailedMessage(e) + "]");
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue