Bug fix, last optimised value in ESUTF8StreamJsonParser kept old value.#135184
Bug fix, last optimised value in ESUTF8StreamJsonParser kept old value.#135184gmarouli merged 21 commits intoelastic:mainfrom
ESUTF8StreamJsonParser kept old value.#135184Conversation
|
Hi @gmarouli, I've created a changelog YAML for you. |
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
martijnvg
left a comment
There was a problem hiding this comment.
Thanks Mary!
I think you also need to undo a part #135172 did: https://github.com/elastic/elasticsearch/pull/135172/files#diff-8ef1741dbe67a9d21e8154754d17238802a9b21344f997067befe4f618f985feR145 ?
I think it would be great if we can get a unit test that reproduces the issue. For example a json document that we know caused the logsdb randomized tests to fail. If we need a DotExpandingXContentParser to reproduce that should be ok. We should reproduce a the bug, which is that an incorrect value is returned for a specific field.
I think the unit test coverage needs to be improved. Maybe we should create a unit test that parses a random json document. First with a parser that never uses the uff-8 parsing optimization and secondly with a parser that uses the utf-8 parsing optimization. Both parsers should produce the exact same result. (I think we can let both parsers something like a map of maps). In order to make it more evil, we can randomly invoke text() or optimizedText() multiple times.
...impl/src/test/java/org/elasticsearch/xcontent/provider/json/ESUTF8StreamJsonParserTests.java
Outdated
Show resolved
Hide resolved
ESUTF8StreamJsonParser kept old value.ESUTF8StreamJsonParser kept old value.
This reverts commit 5851594.
|
Hi @gmarouli, I've updated the changelog YAML for you. |
...impl/src/test/java/org/elasticsearch/xcontent/provider/json/ESUTF8StreamJsonParserTests.java
Outdated
Show resolved
Hide resolved
|
Changed to non-issue to remove the changelog. |
ESUTF8StreamJsonParser kept old value.ESUTF8StreamJsonParser kept old value.
...impl/src/test/java/org/elasticsearch/xcontent/provider/json/ESUTF8StreamJsonParserTests.java
Outdated
Show resolved
Hide resolved
...impl/src/test/java/org/elasticsearch/xcontent/provider/json/ESUTF8StreamJsonParserTests.java
Outdated
Show resolved
Hide resolved
...impl/src/test/java/org/elasticsearch/xcontent/provider/json/ESUTF8StreamJsonParserTests.java
Show resolved
Hide resolved
|
Thanks for the feedback @martijnvg , it is much simpler now and I learned a few extra things. I extended the existing test to capture both bugs we encountered. |
martijnvg
left a comment
There was a problem hiding this comment.
Left one testing suggestion, otherwise LGTM.
...impl/src/test/java/org/elasticsearch/xcontent/provider/json/ESUTF8StreamJsonParserTests.java
Show resolved
Hide resolved
💔 Backport failed
You can use sqren/backport to manually backport by running |
In #134790 we introduced a bug that was caught by our tests.;
The problem manifested itself when a multi field mapper would call
getText()which would set_tokenIncompleteto false after thegetOptimisedText(). This would evaluate the condition_currToken == JsonToken.VALUE_STRING && _tokenIncomplete && stringEnd > 0to false and thelastOptimisedValuewould not be reset.We changed the code to always reset the
lastOptimisedValuewhen anext*()method is called.Furthermore, we introduced a randomised unit test that creates two
XContentParsers and runs one as a baseline using none of the optimised code and the other one is accessing both optimised and non optimised in a random pattern. This test was able to catch both #134770 & #135256.Fixes #135256