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

SNAPSHOT: Repo Creation out of ClusterStateTask #36157

Merged
merged 5 commits into from Dec 4, 2018

Conversation

original-brownbear
Copy link
Member

Addresses this comment #9488 (comment)

* Move `createRepository` call out of cluster state tasks
    * Now only `RepositoriesService#applyClusterState` manipulates `this.repositories`
* Closes elastic#9488
@original-brownbear original-brownbear added >bug WIP :Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v7.0.0 v6.6.0 labels Dec 3, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@@ -371,18 +378,15 @@ private boolean registerRepository(RepositoryMetaData repositoryMetaData) throws
return false;
}
}
Repository newRepo = createRepository(repositoryMetaData);
createRepository(repositoryMetaData);
if (previous != null) {
closeRepository(previous);
Copy link
Contributor

Choose a reason for hiding this comment

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

that looks dangerous now (i.e., closing the existing repo). You should rather close the temporarily created repository.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, the existing one is closed in org.elasticsearch.repositories.RepositoriesService#applyClusterState anyway as far as I can see :)

@@ -362,7 +369,7 @@ public Repository repository(String repositoryName) {
* @param repositoryMetaData new repository metadata
* @return {@code true} if new repository was added or {@code false} if it was ignored
*/
private boolean registerRepository(RepositoryMetaData repositoryMetaData) throws IOException {
private boolean registerRepository(RepositoryMetaData repositoryMetaData) {
Repository previous = repositories.get(repositoryMetaData.name());
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this logic is still needed. If we want to keep the logic to check if there have been no changes, we should just take the current repository metadata from the cluster state, and do this on the cluster state update task.

Copy link
Contributor

Choose a reason for hiding this comment

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

you can then also inline this method so that it only becomes something like

try {
    closeRepository(createRepository(newRepositoryMetaData));
} catch (Exception e) {
    registrationListener.onFailure(e);
    return;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense :) Inlined as you suggest above and added a breakout to the cluster state task for the case of equal metadata.

@original-brownbear
Copy link
Member Author

@ywelsch thanks for taking a look! Applied your suggestions now :)

Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

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

Can you add tests as well for the case where the repo with same settings exist? I'm not sure we have an existing test case for that (maybe look in RepositoriesIT)

@original-brownbear
Copy link
Member Author

@ywelsch sure, done in 546d0fc :)

@ywelsch ywelsch added >enhancement and removed >bug labels Dec 4, 2018
Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

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

LGTM

@original-brownbear
Copy link
Member Author

@ywelsch thanks :)

@original-brownbear original-brownbear merged commit 3c54b41 into elastic:master Dec 4, 2018
original-brownbear added a commit that referenced this pull request Dec 4, 2018
* Move `createRepository` call out of cluster state tasks
    * Now only `RepositoriesService#applyClusterState` manipulates `this.repositories`
* Closes #9488
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >enhancement v6.6.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants