diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java b/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java index 1e2264593310d..5ef7afffe17ec 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java @@ -256,7 +256,7 @@ private void startNewSnapshots(SnapshotsInProgress snapshotsInProgress) { // due to CS batching we might have missed the INIT state and straight went into ABORTED // notify cluster-manager that abort has completed by moving to FAILED if (shard.getValue().state() == ShardState.ABORTED && localNodeId.equals(shard.getValue().nodeId())) { - notifyFailedSnapshotShard(snapshot, shard.getKey(), shard.getValue().reason()); + notifyFailedSnapshotShard(snapshot, shard.getKey(), shard.getValue().reason(), shard.getValue().generation()); } } else { snapshotStatus.abortIfNotCompleted("snapshot has been aborted"); @@ -314,7 +314,7 @@ public void onFailure(Exception e) { logger.warn(() -> new ParameterizedMessage("[{}][{}] failed to snapshot shard", shardId, snapshot), e); } snapshotStatus.moveToFailed(threadPool.absoluteTimeInMillis(), failure); - notifyFailedSnapshotShard(snapshot, shardId, failure); + notifyFailedSnapshotShard(snapshot, shardId, failure, snapshotStatus.generation()); } } ); @@ -594,10 +594,15 @@ private void notifySuccessfulSnapshotShard(final Snapshot snapshot, final ShardI /** Notify the cluster-manager node that the given shard failed to be snapshotted **/ private void notifyFailedSnapshotShard(final Snapshot snapshot, final ShardId shardId, final String failure) { + notifyFailedSnapshotShard(snapshot, shardId, failure, null); + } + + /** Notify the cluster-manager node that the given shard failed to be snapshotted **/ + private void notifyFailedSnapshotShard(final Snapshot snapshot, final ShardId shardId, final String failure, String generation) { sendSnapshotShardUpdate( snapshot, shardId, - new ShardSnapshotStatus(clusterService.localNode().getId(), ShardState.FAILED, failure, null) + new ShardSnapshotStatus(clusterService.localNode().getId(), ShardState.FAILED, failure, generation) ); }