|
@@ -123,6 +123,8 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|
|
*/
|
|
|
public static final Version NO_REPO_INITIALIZE_VERSION = Version.V_7_5_0;
|
|
|
|
|
|
+ public static final Version SHARD_GEN_IN_REPO_DATA_VERSION = Version.V_8_0_0;
|
|
|
+
|
|
|
private static final Logger logger = LogManager.getLogger(SnapshotsService.class);
|
|
|
|
|
|
private final ClusterService clusterService;
|
|
@@ -803,7 +805,8 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|
|
logger.warn("failing snapshot of shard [{}] on closed node [{}]",
|
|
|
shardEntry.key, shardStatus.nodeId());
|
|
|
shards.put(shardEntry.key,
|
|
|
- new ShardSnapshotStatus(shardStatus.nodeId(), ShardState.FAILED, "node shutdown"));
|
|
|
+ new ShardSnapshotStatus(shardStatus.nodeId(), ShardState.FAILED, "node shutdown",
|
|
|
+ shardStatus.generation()));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -908,7 +911,8 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|
|
// Shard that we were waiting for has started on a node, let's process it
|
|
|
snapshotChanged = true;
|
|
|
logger.trace("starting shard that we were waiting for [{}] on node [{}]", shardId, shardStatus.nodeId());
|
|
|
- shards.put(shardId, new ShardSnapshotStatus(shardRouting.primaryShard().currentNodeId()));
|
|
|
+ shards.put(shardId,
|
|
|
+ new ShardSnapshotStatus(shardRouting.primaryShard().currentNodeId(), shardStatus.generation()));
|
|
|
continue;
|
|
|
} else if (shardRouting.primaryShard().initializing() || shardRouting.primaryShard().relocating()) {
|
|
|
// Shard that we were waiting for hasn't started yet or still relocating - will continue to wait
|
|
@@ -920,7 +924,8 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|
|
// Shard that we were waiting for went into unassigned state or disappeared - giving up
|
|
|
snapshotChanged = true;
|
|
|
logger.warn("failing snapshot of shard [{}] on unassigned shard [{}]", shardId, shardStatus.nodeId());
|
|
|
- shards.put(shardId, new ShardSnapshotStatus(shardStatus.nodeId(), ShardState.FAILED, "shard is unassigned"));
|
|
|
+ shards.put(shardId, new ShardSnapshotStatus(
|
|
|
+ shardStatus.nodeId(), ShardState.FAILED, "shard is unassigned", shardStatus.generation()));
|
|
|
} else {
|
|
|
shards.put(shardId, shardStatus);
|
|
|
}
|
|
@@ -1224,7 +1229,8 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|
|
for (ObjectObjectCursor<ShardId, ShardSnapshotStatus> shardEntry : snapshotEntry.shards()) {
|
|
|
ShardSnapshotStatus status = shardEntry.value;
|
|
|
if (status.state().completed() == false) {
|
|
|
- status = new ShardSnapshotStatus(status.nodeId(), ShardState.ABORTED, "aborted by snapshot deletion");
|
|
|
+ status = new ShardSnapshotStatus(
|
|
|
+ status.nodeId(), ShardState.ABORTED, "aborted by snapshot deletion", status.generation());
|
|
|
}
|
|
|
shardsBuilder.put(shardEntry.key, status);
|
|
|
}
|
|
@@ -1410,8 +1416,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|
|
IndexMetaData indexMetaData = metaData.index(indexName);
|
|
|
if (indexMetaData == null) {
|
|
|
// The index was deleted before we managed to start the snapshot - mark it as missing.
|
|
|
- builder.put(new ShardId(indexName, IndexMetaData.INDEX_UUID_NA_VALUE, 0),
|
|
|
- new SnapshotsInProgress.ShardSnapshotStatus(null, ShardState.MISSING, "missing index"));
|
|
|
+ builder.put(new ShardId(indexName, IndexMetaData.INDEX_UUID_NA_VALUE, 0), missingStatus(null, "missing index"));
|
|
|
} else {
|
|
|
IndexRoutingTable indexRoutingTable = clusterState.getRoutingTable().index(indexName);
|
|
|
for (int i = 0; i < indexMetaData.getNumberOfShards(); i++) {
|
|
@@ -1419,20 +1424,18 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|
|
if (indexRoutingTable != null) {
|
|
|
ShardRouting primary = indexRoutingTable.shard(i).primaryShard();
|
|
|
if (primary == null || !primary.assignedToNode()) {
|
|
|
- builder.put(shardId,
|
|
|
- new SnapshotsInProgress.ShardSnapshotStatus(null, ShardState.MISSING, "primary shard is not allocated"));
|
|
|
+ builder.put(shardId, missingStatus(null, "primary shard is not allocated"));
|
|
|
} else if (primary.relocating() || primary.initializing()) {
|
|
|
- builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(primary.currentNodeId(), ShardState.WAITING));
|
|
|
+ builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(
|
|
|
+ primary.currentNodeId(), ShardState.WAITING, null));
|
|
|
} else if (!primary.started()) {
|
|
|
- builder.put(shardId,
|
|
|
- new SnapshotsInProgress.ShardSnapshotStatus(primary.currentNodeId(), ShardState.MISSING,
|
|
|
- "primary shard hasn't been started yet"));
|
|
|
+ builder.put(shardId, missingStatus(primary.currentNodeId(), "primary shard hasn't been started yet"));
|
|
|
} else {
|
|
|
- builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(primary.currentNodeId()));
|
|
|
+ builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(
|
|
|
+ primary.currentNodeId(), null));
|
|
|
}
|
|
|
} else {
|
|
|
- builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(null, ShardState.MISSING,
|
|
|
- "missing routing table"));
|
|
|
+ builder.put(shardId, missingStatus(null, "missing routing table"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1441,6 +1444,10 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|
|
return builder.build();
|
|
|
}
|
|
|
|
|
|
+ private static ShardSnapshotStatus missingStatus(@Nullable String nodeId, String reason) {
|
|
|
+ return new SnapshotsInProgress.ShardSnapshotStatus(nodeId, ShardState.MISSING, reason, null);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Returns the indices that are currently being snapshotted (with partial == false) and that are contained in the indices-to-check set.
|
|
|
*/
|