-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
With recent fixes it is never correct to simply remove a snapshot from the cluster state without updating other snapshot entries if an entry contains any successful shards due to possible dependencies. This change reproduces two issues resulting from simply removing snapshot without regard for other queued operations and fixes them by having all removal of snapshot from the cluster state go through the same code path. Also, this change moves the tracking of a snapshot as "ending" up a few lines to fix an assertion about finishing snapshots that forces them to be in this collection.
- Loading branch information
1 parent
b509b9f
commit 9bb770e
Showing
18 changed files
with
323 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
server/src/main/java/org/elasticsearch/repositories/FinalizeSnapshotContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.repositories; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.metadata.Metadata; | ||
import org.elasticsearch.core.Tuple; | ||
import org.elasticsearch.snapshots.SnapshotInfo; | ||
import org.elasticsearch.snapshots.SnapshotsService; | ||
|
||
/** | ||
* Context for finalizing a snapshot. | ||
*/ | ||
public final class FinalizeSnapshotContext extends ActionListener.Delegating< | ||
Tuple<RepositoryData, SnapshotInfo>, | ||
Tuple<RepositoryData, SnapshotInfo>> { | ||
|
||
private final ShardGenerations updatedShardGenerations; | ||
|
||
private final long repositoryStateId; | ||
|
||
private final Metadata clusterMetadata; | ||
|
||
private final SnapshotInfo snapshotInfo; | ||
|
||
private final Version repositoryMetaVersion; | ||
|
||
/** | ||
* @param updatedShardGenerations updated shard generations | ||
* @param repositoryStateId the unique id identifying the state of the repository when the snapshot began | ||
* @param clusterMetadata cluster metadata | ||
* @param snapshotInfo SnapshotInfo instance to write for this snapshot | ||
* @param repositoryMetaVersion version of the updated repository metadata to write | ||
* @param listener listener to be invoked with the new {@link RepositoryData} and {@link SnapshotInfo} after completing | ||
* the snapshot | ||
*/ | ||
public FinalizeSnapshotContext( | ||
ShardGenerations updatedShardGenerations, | ||
long repositoryStateId, | ||
Metadata clusterMetadata, | ||
SnapshotInfo snapshotInfo, | ||
Version repositoryMetaVersion, | ||
ActionListener<Tuple<RepositoryData, SnapshotInfo>> listener | ||
) { | ||
super(listener); | ||
this.updatedShardGenerations = updatedShardGenerations; | ||
this.repositoryStateId = repositoryStateId; | ||
this.clusterMetadata = clusterMetadata; | ||
this.snapshotInfo = snapshotInfo; | ||
this.repositoryMetaVersion = repositoryMetaVersion; | ||
} | ||
|
||
public long repositoryStateId() { | ||
return repositoryStateId; | ||
} | ||
|
||
public ShardGenerations updatedShardGenerations() { | ||
return updatedShardGenerations; | ||
} | ||
|
||
public SnapshotInfo snapshotInfo() { | ||
return snapshotInfo; | ||
} | ||
|
||
public Version repositoryMetaVersion() { | ||
return repositoryMetaVersion; | ||
} | ||
|
||
public Metadata clusterMetadata() { | ||
return clusterMetadata; | ||
} | ||
|
||
public ClusterState updatedClusterState(ClusterState state) { | ||
return SnapshotsService.stateWithoutSnapshot(state, snapshotInfo.snapshot()); | ||
} | ||
|
||
@Override | ||
public void onResponse(Tuple<RepositoryData, SnapshotInfo> repositoryData) { | ||
delegate.onResponse(repositoryData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.