Skip to content

Commit 6c32443

Browse files
Remove Redundant Cluster State during Snapshot INIT + Master Failover (#54420)
* Remove Redundant Cluster State during Snapshot INIT + Master Failover Similar to #54395 we know that a snapshot in INIT state has not written anything to the repository yet. If we see one from a master failover, there is no point in moving it to ABORTED before removing it from the cluster state in a subsequent CS update. Instead, we can simply remove its job from the CS the first time we see it on master failover and be done with it.
1 parent c7da75a commit 6c32443

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -827,22 +827,8 @@ public ClusterState execute(ClusterState currentState) {
827827
entries.add(updatedSnapshot);
828828
} else if (snapshot.state() == State.INIT && initializingSnapshots.contains(snapshot.snapshot()) == false) {
829829
changed = true;
830-
// Mark the snapshot as aborted as it failed to start from the previous master
831-
updatedSnapshot = new SnapshotsInProgress.Entry(snapshot, State.ABORTED, snapshot.shards());
832-
entries.add(updatedSnapshot);
833-
834-
// Clean up the snapshot that failed to start from the old master
835-
deleteSnapshot(snapshot.snapshot(), new ActionListener<>() {
836-
@Override
837-
public void onResponse(Void aVoid) {
838-
logger.debug("cleaned up abandoned snapshot {} in INIT state", snapshot.snapshot());
839-
}
840-
841-
@Override
842-
public void onFailure(Exception e) {
843-
logger.warn("failed to clean up abandoned snapshot {} in INIT state", snapshot.snapshot());
844-
}
845-
}, updatedSnapshot.repositoryStateId(), false);
830+
// A snapshot in INIT state hasn't yet written anything to the repository so we simply remove it
831+
// from the cluster state without any further cleanup
846832
}
847833
assert updatedSnapshot.shards().size() == snapshot.shards().size()
848834
: "Shard count changed during snapshot status update from [" + snapshot + "] to [" + updatedSnapshot + "]";

0 commit comments

Comments
 (0)