-
Notifications
You must be signed in to change notification settings - Fork 107
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
Execute item failure callback on bulk request error #627
Execute item failure callback on bulk request error #627
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #627 +/- ##
===========================================
+ Coverage 57.29% 68.06% +10.76%
===========================================
Files 315 376 +61
Lines 9823 8867 -956
===========================================
+ Hits 5628 6035 +407
+ Misses 2902 1552 -1350
+ Partials 1293 1280 -13
Flags with carried forward coverage won't be shown. Click here to find out more.
|
8918410
to
77450d3
Compare
I ordered the execution of the item My thought process was if the |
77450d3
to
f416719
Compare
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.
Looks good!
Let's take this opportunity and add a few more tests to cover the edge cases (some may exist)?
- fails only some items and makes sure that
failedItems
is correct - checks that OnError is called every time, and only once, if there's at least one failure
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.
Actually looking at the code I see https://github.com/opensearch-project/opensearch-go/pull/627/files#diff-84320628b2df1ee872c513a0e5a15df089c6116a5c2b6e8d4d577102e0bcb6c6R526 that calls onFailure
below if the response is > 201.
Something seems fishy, it's now either called twice, or it was correct before and there's another reason why it wasn't called.
Correct that But if the whole bulk request errors, for example if OpenSearch goes down while the request is in flight, or the context deadlines, the flush function returns without executing the item failure callbacks and the workers buffer is cleared. So those items are lost and their callbacks are never executed. |
Understood. And just to double-check, we don't call those callbacks twice in the successful response but some failed items case? Add a test for this? |
Yep the failure callback will only be executed once. If the response is successful (the error here is nil), the code in this PR is never hit. My unit test I added has a check to make sure that the number of times the failure callback is executed is what is expected i.e. nothing is called twice. |
I think there's still a test missing for partial failure on some of the items, you want to check that if you have 5 items and 2 failures the callback is only called twice, for example? |
I think this unit test earlier in the file already covers that? Specifically this check here in the unit test: I might be misunderstanding though, I'm happy to add more if that's not the use case you're referring too. |
First, thank you for hanging in here with me ;) The old code did not call Without trying, some examples where I think all tests pass but the code is broken: call |
Ah gotcha gotcha, sorry for some much back and forth 😄. Let me update the other tests to check for this. |
No stress! I enjoy this type of conversations because I am super OCD about tests :) |
915f706
to
b9a352c
Compare
Signed-off-by: Kellen Miller <[email protected]>
b9a352c
to
3cee55e
Compare
As you should be! I've update the test to maintain a map of Let me know if there's any other test updates needed and if I addressed the test case you were referring to. |
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.
👏
@dblock sorry to bother again! Is there any roadmap or release cadence to this library? Wondering when the process to cut a release with my fix will happen. I can always target |
Open a "release v. Next" issue and we'll take care of it quickly. |
Description
Execute all bulk item failure callbacks (if they exist) in worker's buffer when a bulk request fails.
Issues Resolved
Fixes #626
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.