-
Notifications
You must be signed in to change notification settings - Fork 202
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
Handle errors from OpenSearch by checking status field as well as error #4335
Handle errors from OpenSearch by checking status field as well as error #4335
Conversation
…he error body for each bulk response item. Signed-off-by: David Venable <dlv@amazon.com>
@@ -234,7 +235,7 @@ private BulkOperationRequestResponse handleRetriesAndFailures(final Accumulating | |||
final boolean doRetry = (Objects.isNull(exceptionFromRequest)) ? canRetry(bulkResponse) : canRetry(exceptionFromRequest); | |||
if (!Objects.isNull(bulkResponse) && retryCount == 1) { // first attempt | |||
for (final BulkResponseItem bulkItemResponse : bulkResponse.items()) { | |||
if (bulkItemResponse.error() == null) { | |||
if (!isItemInError(bulkItemResponse)) { | |||
sentDocumentsOnFirstAttemptCounter.increment(); | |||
} | |||
} |
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.
There's another call to BulkResponseItem::error
on line 247 for logging. Not as critical but would be good to have the same check there
// Skip logging the error for version conflicts | ||
final ErrorCause error = bulkItemResponse.error(); | ||
if (error != null && VERSION_CONFLICT_EXCEPTION_TYPE.equals(error.type())) { | ||
break; |
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.
Should this be a continue in case there are non version conflict exceptions later in the response items?
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, definitely. Thanks for catching this!
if (error != null && VERSION_CONFLICT_EXCEPTION_TYPE.equals(error.type())) { | ||
break; | ||
} | ||
LOG.warn("operation = {}, status = {}, error = {}", bulkItemResponse.operationType(), bulkItemResponse.status(), error != null ? error.reason() : ""); | ||
} | ||
} | ||
handleFailures(bulkRequest, bulkResponse.items()); |
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.
Could we do a similar rest status check on line 290 as well for the BulkResponse?
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.
Are you referring to this line?
if (bulkResponse.errors()) {
I think you are suggesting that we also check the status of the HTTP response. I don't see any methods supporting this on this class. I believe that the client will throw an exception if the whole HTTP status is an error status. That's what this catch is for:
} catch (Exception e) {
incrementErrorCounters(e);
return handleRetriesAndFailures(bulkRequestForRetry, retryCount, null, 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.
Got it, makes sense
Signed-off-by: David Venable <dlv@amazon.com>
Description
It appears that for some situations, Amazon OpenSearch Serverless is not including the
error
field in bulk response errors. This PR includes a check on thestatus
field as well.Issues Resolved
N/A
Check List
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.