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

Deleting multiple indices can fail to report all failures #11189

Closed
wants to merge 1 commit into from
Closed

Deleting multiple indices can fail to report all failures #11189

wants to merge 1 commit into from

Conversation

memcmp
Copy link

@memcmp memcmp commented May 15, 2015

currently a delete is performed for every concreteIndex within the DeleteIndexRequest.
If an error occurs the exception is assigned to lastFailure and after the last delete is performed the error is passed to the listener (if one did occur).

The problem is that lastFailure is declared within the listeners passed to deleteIndexService.deleteIndex and so only the failure of the last deleted index is considered and the errors of previous deleted indices are ignored. This patch fixes this behavior by declaring lastFailure outside the loop.

i had problems creating a proper test for this, maybe one of you can point me into the right direction or show me a similar test

for (final String index : concreteIndices) {
deleteIndexService.deleteIndex(new MetaDataDeleteIndexService.Request(index).timeout(request.timeout()).masterTimeout(request.masterNodeTimeout()), new MetaDataDeleteIndexService.Listener() {

private volatile Throwable lastFailure;
private volatile boolean ack = true;
Copy link
Member

Choose a reason for hiding this comment

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

can we move ack too together with lastFailure please?

@javanna
Copy link
Member

javanna commented May 15, 2015

Thanks for sending this PR @bogensberger , this relates to #7295. We will still have to improve the delete index api at some point so that we return a list of errors rather than just the last one, but this fix already improves things. I left a small comment, can you also sign our CLA please?

@clintongormley
Copy link

Could we also have a better description for the PR? I don't understand what it is doing.

thanks

@memcmp
Copy link
Author

memcmp commented May 18, 2015

@javanna i've signed the CLA and updated the commit so ack is also moved.

@memcmp
Copy link
Author

memcmp commented May 18, 2015

@clintongormley i've updated the PR description. I hope it's more clear now.

@@ -83,22 +84,22 @@ protected void masterOperation(final DeleteIndexRequest request, final ClusterSt
}
// TODO: this API should be improved, currently, if one delete index failed, we send a failure, we should send a response array that includes all the indices that were deleted
final CountDown count = new CountDown(concreteIndices.length);
final AtomicReference<Throwable> lastFailure = new AtomicReference<>();
final AtomicReference<Boolean> ack = new AtomicReference<>(true);
Copy link
Member

Choose a reason for hiding this comment

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

I think AtomicBoolean would be better instead of AtomicReference<Boolean>?

Copy link
Author

Choose a reason for hiding this comment

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

ah sry, AtomicBoolean is better of course - updated

@javanna
Copy link
Member

javanna commented May 18, 2015

thanks @bogensberger I just left a small comment, thanks a lot for updating, I will look into writing a test for this and merge it.

if the last delete operation succeeded
@memcmp
Copy link
Author

memcmp commented May 20, 2015

@javanna Thanks for review i've updated the pull request. I have also created another PR (#11258) which also relates to #7295

@clintongormley clintongormley changed the title Fix: Deleting multiple indices defrauded errors Deleting multiple indices can fail to report all failures May 25, 2015
@clintongormley clintongormley added the :Data Management/Indices APIs APIs to create and manage indices and templates label May 25, 2015
@clintongormley clintongormley assigned s1monw and unassigned javanna Jun 26, 2015
@@ -83,22 +85,22 @@ protected void masterOperation(final DeleteIndexRequest request, final ClusterSt
}
// TODO: this API should be improved, currently, if one delete index failed, we send a failure, we should send a response array that includes all the indices that were deleted
final CountDown count = new CountDown(concreteIndices.length);
final AtomicReference<Throwable> lastFailure = new AtomicReference<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we somehow make this a synchronized list and report all failures? I'd just add 2-N failures as suppressed to the first?

@s1monw
Copy link
Contributor

s1monw commented Oct 16, 2015

@javanna can you come back to this? I added a comment but you worked on it before so I wonder if you have something to add?

@javanna
Copy link
Member

javanna commented Oct 19, 2015

I agree with your comment @s1monw . I'd love to have a simple test for it as well, I meant to come up with one but I never got to it :(

@s1monw
Copy link
Contributor

s1monw commented Oct 27, 2015

is this fixed by #11258 ?

@memcmp
Copy link
Author

memcmp commented Oct 27, 2015

@s1monw yes #11258 also fixes this issue.

@javanna
Copy link
Member

javanna commented Oct 27, 2015

great closing then, thanks again @bogensberger ! Superseded by #11258 .

@javanna javanna closed this Oct 27, 2015
@s1monw
Copy link
Contributor

s1monw commented Oct 27, 2015

awesome!

@s1monw
Copy link
Contributor

s1monw commented Oct 27, 2015

@javanna I labeled it fixed in 2.2 and 3.0 no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Data Management/Indices APIs APIs to create and manage indices and templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants