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

Failed preparsing does not fail whole bulk request #4781

Merged

Conversation

spinscale
Copy link
Contributor

If a preparsing of the source is needed (due to mapping configuration,
which extracts the routing/id value from the source) and the source is not
valid JSON, then the whole bulk request is failed instead of a single
BulkRequest.

This commit ensures, that a broken JSON request is not forwarded to the
destination shard and creates an appropriate BulkItemResponse, which
includes a failure.

This also implied changing the BulkItemResponse serialization, because one
cannot be sure anymore, if a response includes an ID, in case it was not
specified and could not be extracted from the JSON.

Closes #4745

@@ -264,7 +264,7 @@ public void readFrom(StreamInput in) throws IOException {
if (in.readBoolean()) {
String fIndex = in.readSharedString();
String fType = in.readSharedString();
String fId = in.readString();
String fId = in.readOptionalString();
Copy link
Contributor

Choose a reason for hiding this comment

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

well I guess that was a problem before so we don't need conditional reads / writes here depending on the version? I wonder when this can be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be null, if you try to extract the ID from a broken JSON and thus fail.

This hasnt popped up before, because the whole request failed and so there was no need to send this single BulkItemResponse over the wire.

@s1monw
Copy link
Contributor

s1monw commented Jan 20, 2014

LGTM - added a small comment

If a preparsing of the source is needed (due to mapping configuration,
which extracts the routing/id value from the source) and the source is not
valid JSON, then the whole bulk request is failed instead of a single
BulkRequest.

This commit ensures, that a broken JSON request is not forwarded to the
destination shard and creates an appropriate BulkItemResponse, which
includes a failure.

This also implied changing the BulkItemResponse serialization, because one
cannot be sure anymore, if a response includes an ID, in case it was not
specified and could not be extracted from the JSON.

Closes elastic#4745
@spinscale spinscale merged commit 35e5432 into elastic:master Jan 27, 2014
@clintongormley clintongormley changed the title Bulk: Failed preparsing does not fail whole bulk request Failed preparsing does not fail whole bulk request Jun 8, 2015
@lcawl lcawl added :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. and removed :Bulk labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. v0.90.11 v1.0.0.RC2 v1.1.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enabling "_timestamp" can cause bulk API to fail entire request instead of single operation
4 participants