-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Bulk insert with script behaves incorrectly #48670
Comments
Pinging @elastic/es-core-infra (:Core/Infra/Scripting) |
Thanks for simple reproduction instructions. I was able to reproduce this and track down the problem. A scripted upsert for the first doc in a bulk request may run many times (for me it ran only once, and thus I got I'm moving this to the distrib team to determine the best fix. Seems like we need to either make the operation idempotent, so the potential subsequent runs start with a fresh doc again, or start and wait on mapping updates before even attempting to index the doc on the primary. |
Pinging @elastic/es-distributed (:Distributed/CRUD) |
I've created a fix here: #49578 |
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
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
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
One possible workaround is to ensure the mappings are in place on the index before doing the update, avoiding the dynamic mapping update. |
@henningandersen Thanks! This was very helpful |
I am using an official ES docker container: docker.elastic.co/elasticsearch/elasticsearch:7.4.1
Elasticsearch version (
bin/elasticsearch --version
):Version: 7.4.1, Build: default/docker/fc0eeb6e2c25915d63d871d344e3d0b45ea0ea1e/2019-10-22T17:16:35.176724Z, JVM: 13
I also tried 7.3.2 and 7.2.1, they all experience this issue.
Plugins installed: []
JVM version (
java -version
):openjdk version "13" 2019-09-17
OpenJDK Runtime Environment AdoptOpenJDK (build 13+33)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13+33, mixed mode, sharing)
OS version (
uname -a
if on a Unix-like system):Linux fa18f15fe8f0 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Description of the problem including expected versus actual behavior:
When using bulk upsert with a "painless" script, first document in a batch seems to be handled incorrectly.
Steps to reproduce:
Perform this bulk insert into an index that doesn't yet contain documents with these ids:
In this example I am inserting the same thing twice, only
_id
value is different, so I expect two identical documents to be inserted into the ES.Query the index:
Note that the
counter
field for the first document is incorrect and is different from thecounter
field value from the second document.3
is a correct value and7
is not a correct value according to my expectations.The text was updated successfully, but these errors were encountered: