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
DocumentMissingException is also thrown on update retries #6724
DocumentMissingException is also thrown on update retries #6724
Conversation
peschlowp
commented
Jul 4, 2014
- Closes Indexing: DocumentMissingException is uncaught if thrown during retry of update request #6355.
- Contains the bugfix and an integration test demonstrating the bug and validating the fix.
- The fix in TransportUpdateAction is a simple try-catch block calling the appropriate failure handler. The fix prevents DocumentMissingExceptions from ending up uncaught and thus makes sure that an HTTP response is actually sent to the client instead of not sending any at all.
sorry for the delay - I will look into this soon. Did you sign the CLA so I can pull it in once ready? |
Glad to hear that this is going to be reviewed! I recently signed a CLA for contributing some typo fixes to The Definitive Guide - if it is the same CLA, then I'm already done. |
shardOperation(request, listener, retryCount + 1); | ||
try { | ||
shardOperation(request, listener, retryCount + 1); | ||
} catch (DocumentMissingException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should just catch Throwable I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, catching Throwable might be even better to handle other cases as well. I was restricting myself to fix just the error situation I observed :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While at it, we might also consider adding similar try-catch blocks to two other cases (UPSERT, DELETE) of the surrounding switch statement.
If that's the way to go, I can modify my changes accordingly and also add further tests validating behavior for those other error cases. (So far I only added a test for that DocumentMissingException occurring during update request retries.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, make sense
hey, I really appreciate your testcase though but it's kind of very involved and should use our testing infrastructure. Maybe take a look at I also wonder if we should fix this in more places I can see 2 more places where we do run public abstract class ActionRunnable implements Runnable {
protected final ActionListener<?> listener
public ActionRunnable(ActionListener<?> listener ){
this.listener = listener;
}
public final void run() {
try {
doRun();
} catch (Throwable t) {
listener.onFailure(t);
}
}
protected abstract void doRun();
} |
I'm currently adding test cases for the two other places in TransportUpdateAction, to have the logic in place at all. I'm going to update the pull request once I'm done. It's not a big deal to add the Runnable implementation you provide so I'll do that as well. Actually, I took a look at ElasticsearchIntegrationTest before starting to write the initial test, but unfortunately it uses a specific implementation of Engine, and I need another one to force the timing between requests. As an Elasticsearch codebase newbie, I didn't want to mess with that so I went for a self-contained solution. Still, I'd be glad to have these tests based on the existing infrastructure. Note that another constraint is that I need to access the Engine instance from the test code, and it is not easy to get the respective injector at that point (as it is the index' injector, not the node's). Do you have a good suggestion for fitting it into ElasticsearchIntegrationTest? |
@peschlowp if you want to use a different engine that is pretty simple you can create an index like this: public void testX() {
assertAcked(prepareCreate("idx").setSettings(ImmutableSettings.builder()
.put(IndexEngineModule.EngineSettings.ENGINE_TYPE, YourEngineModule.class.getName());
// go do your thing...
} lemme know if it works |
Pushed an update applying the try-catch fix to all three locations, for you to review and give me feedback on two open questions:
Note that I didn't create a separate ActionRunnable class yet, this can be added when the above points are resolved. |
Sorry for the confusion, I introduced a timing bug in one of my test cases while refactoring it and blamed the integration test infrastructure for it. It is fixed now and the tests are running stable on my machine :-) Also, I added the ActionRunnable @s1monw proposed. Aside from the question if the retry logic is needed at all for delete requests (see point 2 in my last comment), I'm satisfied now. If your review also turns out satisfactory, I can squash the various commits to a single one that you can actually pull. |
* Tests to demonstrate the bug discussed in issue #6355 and pull request #6724. The tests validate the fix for that bug | ||
* and similar situations. | ||
*/ | ||
@ClusterScope(scope = Scope.SUITE, numDataNodes = 1, numClientNodes = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed you can run with default scope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Seems I was overly cautious when turning it into an ElasticsearchIntegrationTest. But as long as I only use my own internal engine implementation within my test indexes, everything is fine. Going to remove the annotation line completely.
I left a couple of cosmetic comments I think we are ready to squash good job! |
Closes elastic#6355. Also contains an integration test demonstrating the bug and validating the fix.
OK, all done, including a few more cosmetic changes, and squashed. Feel free to refactor whatever you like after pulling, I probably haven't followed all conventions of the project everywhere. Happy that I could contribute to Elasticsearch. |
thanks for the report and the fix! I will push this in a bit.. |
Throwables thrown on update retries are now caught and handled via the provided callback. This commit also contains an integration test demonstrating the bug and validating the fix. Closes elastic#6355 Closes elastic#6724