Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Consistent ClusterState throughout Snapshot API Calls #51464

Conversation

original-brownbear
Copy link
Member

@original-brownbear original-brownbear commented Jan 26, 2020

We shouldn't be using potentially changing versions of the cluster state
when answering a snapshot status API call by calling SnapshotService#currentSnapshots multiple times (each time using ClusterService#state under the hood) but instead pass down the state from the transport action.
Having these API behave more in a more deterministic way will make it easier to use them once parallel repository operations
are introduced.

We shouldn't be using potentially changing versions of the cluster state
when answering a snapshot status API call. Having these API behave more
deterministically will make it easier to use them once parallel repository operations
are introduced.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/Snapshot/Restore)

@@ -1222,7 +1226,8 @@ public void deleteSnapshot(final String repositoryName, final String snapshotNam
// if nothing found by the same name, then look in the cluster state for current in progress snapshots
long repoGenId = repositoryData.getGenId();
if (matchedEntry.isPresent() == false) {
Optional<SnapshotsInProgress.Entry> matchedInProgress = currentSnapshots(repositoryName, Collections.emptyList()).stream()
Optional<SnapshotsInProgress.Entry> matchedInProgress = currentSnapshots(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the fact that we're using a potentially racy CS here, leading to some needless snapshot delete failures, obvious was the main motivation behind this change actually (a bigger change to deletes making use of this cleanup is coming in #51463).

request.ignoreUnavailable(), request.verbose(), listener)),
listener::onFailure),
GetRepositoriesResponse::new));
}

private void getMultipleReposSnapshotInfo(List<RepositoryMetaData> repos, String[] snapshots, boolean ignoreUnavailable,
boolean verbose, ActionListener<GetSnapshotsResponse> listener) {
private void getMultipleReposSnapshotInfo(ClusterState state, List<RepositoryMetaData> repos, String[] snapshots,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just pass down SnapshotsInProgress? Makes it a bit clearer what the dependencies are

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure sounds good :) => f2efe16

Copy link
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'm happy to see this change. Yannick's comment about SnapshotsInProgress should be addressed before merging if possible (does not seem to have an impact on #51463)

@original-brownbear
Copy link
Member Author

Jenkins run elasticsearch-ci/1 (unrelated but interesting failure in S3 REST mock tests ... link for my reference: https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+pull-request-1/14597/testReport/junit/org.elasticsearch.repositories.s3/S3BlobContainerRetriesTests/testReadBlobWithRetries/ )

ActionListener.map(wrappedListener, snInfos -> GetSnapshotsResponse.Response.snapshots(repoName, snInfos)))));
}
}

private void getSingleRepoSnapshotInfo(String repo, String[] snapshots, boolean ignoreUnavailable, boolean verbose,
ActionListener<List<SnapshotInfo>> listener) {
private void getSingleRepoSnapshotInfo(SnapshotsInProgress snapshotsInProgress, String repo, String[] snapshots,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add @Nullable to the methods that pass SnapshotsInProgress, or alternatively, pass an empty instance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure added the @Nullables in 2bfe8f5 :)

@original-brownbear
Copy link
Member Author

Thanks Tanguy + Yannick!

@original-brownbear original-brownbear merged commit 1e5f77e into elastic:master Jan 27, 2020
@original-brownbear original-brownbear deleted the consistent-cs-for-snapshot-status-apis branch January 27, 2020 10:58
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Jan 27, 2020
)

We shouldn't be using potentially changing versions of the cluster state
when answering a snapshot status API call by calling `SnapshotService#currentSnapshots` multiple times (each time using `ClusterService#state` under the hood) but instead pass down the state from the transport action.
Having these API behave more in a more deterministic way will make it easier to use them once parallel repository operations
are introduced.
original-brownbear added a commit that referenced this pull request Jan 27, 2020
…51471)

We shouldn't be using potentially changing versions of the cluster state
when answering a snapshot status API call by calling `SnapshotService#currentSnapshots` multiple times (each time using `ClusterService#state` under the hood) but instead pass down the state from the transport action.
Having these API behave more in a more deterministic way will make it easier to use them once parallel repository operations
are introduced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants