Skip to content

Do not mutate request on scripted upsert#49578

Merged
ywelsch merged 2 commits intoelastic:masterfrom
ywelsch:scripted-upsert-retry
Nov 27, 2019
Merged

Do not mutate request on scripted upsert#49578
ywelsch merged 2 commits intoelastic:masterfrom
ywelsch:scripted-upsert-retry

Conversation

@ywelsch
Copy link
Copy Markdown
Contributor

@ywelsch ywelsch commented Nov 26, 2019

Fixes a bug where a scripted upsert that causes a dynamic mapping update is retried (because mapping update is still in-flight), and the request is mutated multiple times.

Closes #48670

@ywelsch ywelsch added >bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. v8.0.0 v7.6.0 v7.5.1 labels Nov 26, 2019
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (:Distributed/CRUD)

Copy link
Copy Markdown
Contributor

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

LGTM

final Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx._source.field += 1", Collections.emptyMap());

BulkResponse bulkResponse = client().prepareBulk()
.add(client().prepareUpdate().setIndex(indexOrAlias()).setId("1").setScript(script).setScriptedUpsert(true).setUpsert("field", 1))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This long line is failing checkstyle

Copy link
Copy Markdown
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

LGTM2

@ywelsch ywelsch merged commit 3429f79 into elastic:master Nov 27, 2019
ywelsch added a commit that referenced this pull request Nov 27, 2019
Fixes a bug where a scripted upsert that causes a dynamic mapping update is retried (because
mapping update is still in-flight), and the request is mutated multiple times.

Closes #48670
ywelsch added a commit that referenced this pull request Nov 27, 2019
Fixes a bug where a scripted upsert that causes a dynamic mapping update is retried (because
mapping update is still in-flight), and the request is mutated multiple times.

Closes #48670
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. v7.5.1 v7.6.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk insert with script behaves incorrectly

5 participants