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

feat: better error handling from server bulk response. #149

Merged
merged 2 commits into from
Jan 10, 2022

Conversation

lucianaparaschivei
Copy link
Contributor

@lucianaparaschivei lucianaparaschivei commented Jul 14, 2021

In some cases the BytesResponse flag Success is not enough to identify a failed index operation. We should rely on the BulkResponse that returns the items with errors.

For example this will not log anything in the internal logger with the current approach:
Successful (200) low level call on POST: /_bulk {"took":0,"errors":true,"items":[{"index":{"_index":"logstash-2021.07.12","_type":"_doc","_id":"OTgmmnoBq3Eup03vE24t","status":403,"error":{"type":"security_exception","reason":"action [indices:data/write/bulk[s]] is unauthorized for API key id [NzgjmnoBq3Eup03vg25H] of user [elastic] on indices [logstash-2021.07.12], this action is granted by the index privileges [create_doc,create,delete,index,write,all]"}

But the BulkResponse has the Errors flag and will include in this case the failed item in the ItemsWithErrors collection.

Checklist

@snakefoot
Copy link
Collaborator

snakefoot commented Jul 14, 2021

What is the performance overhead from using NEST BulkResponse ? (Prefer to optimize for success instead of error)

Would it not be possible to extract the same information from the ApiCall-property on BytesResponse ?

I guess it would make sense to stop using the LowLevel-Client and instead, change over to the NEST-interface. Since the LowLevel-Serializer fails to handle anything but simple data-types.

@lucianaparaschivei
Copy link
Contributor Author

lucianaparaschivei commented Jul 15, 2021

I have run some benchmarks and found no real overhead for using the BytesResponse. I would not switch to Nest client as it will add overhead and in reality it is using the low level client anyways. Also I do think it is important to spot errors in the process as we have seen intermittent missing elastic logs without any internal logging.
Here are my results for writing 1 simple log text x 100 times (so enforcing many responses deserialization):

  1. BulkResponse with error:
    image

    BytesResponse with error:
    image

  2. BulkResponse success:
    image
    BytesResponse success:
    image

@snakefoot
Copy link
Collaborator

snakefoot commented Jul 16, 2021

Amazing how sending 100 messages cost 2 MByte allocation. Also strange that BulkResponse does not increase allocation, since it should deserialize the actual response, where BytesResponse just contains the response-as-blob-data.

Have created the following issue elastic/elastic-transport-net#30

@lucianaparaschivei
Copy link
Contributor Author

FYI: 1000 messages will cost 15Mbytes

@stale
Copy link

stale bot commented Aug 22, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 22, 2021
@lucianaparaschivei
Copy link
Contributor Author

activate

@stale stale bot removed the stale label Aug 23, 2021
@snakefoot
Copy link
Collaborator

@lucianaparaschivei Possible that the last commit feat: add support for OAuth tokens could be extracted into a new pull-request?

@lucianaparaschivei
Copy link
Contributor Author

Sure, i added it by mistake.

@stale
Copy link

stale bot commented Jan 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants