-
Notifications
You must be signed in to change notification settings - Fork 72
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
[bug fix] Fix async actions are left in neural_sparse query #438
[bug fix] Fix async actions are left in neural_sparse query #438
Conversation
Signed-off-by: zhichao-aws <[email protected]>
Signed-off-by: zhichao-aws <[email protected]>
Signed-off-by: zhichao-aws <[email protected]>
should be in 2.11 |
Codecov Report
@@ Coverage Diff @@
## 2.11 #438 +/- ##
============================================
+ Coverage 80.71% 80.75% +0.04%
- Complexity 502 510 +8
============================================
Files 41 41
Lines 1576 1590 +14
Branches 241 247 +6
============================================
+ Hits 1272 1284 +12
Misses 201 201
- Partials 103 105 +2
|
Signed-off-by: zhichao-aws <[email protected]>
@@ -276,16 +286,25 @@ private static void validateQueryTokens(Map<String, Float> queryTokens) { | |||
protected boolean doEquals(NeuralSparseQueryBuilder obj) { | |||
if (this == obj) return true; | |||
if (obj == null || getClass() != obj.getClass()) return false; | |||
if (queryTokensSupplier == null && obj.queryTokensSupplier != null) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we need to change formatting in this method, every if case body must be in curly braces, plus for null/not null checks we can utilize Objects static methods. I'm fine with doing this is future, not a blocker for this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's handle the issue when we backport it to 2.x
queryTokensSetOnce.set(Map.of("hello", 1.0f, "world", 2.0f)); | ||
original.queryTokensSupplier(queryTokensSetOnce::get); | ||
|
||
streamOutput = new BytesStreamOutput(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we create a new instance of ByteStreamOutput instead of re-using existent one. That improves readability and lower chance of error. Same for line 306, instance of NamedWriteableAwareStreamInput. Can be done in followup PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's handle the issue when we backport it to 2.x or as a follow up pr.
@@ -89,6 +89,10 @@ public NeuralSparseQueryBuilder(StreamInput in) throws IOException { | |||
this.queryText = in.readString(); | |||
this.modelId = in.readString(); | |||
this.maxTokenScore = in.readOptionalFloat(); | |||
if (in.readBoolean()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a backward compatible change? I think for 2.10 and below versions there will be no boolean at all.
Plus the read - I think you can do same with readOptional method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to clarify my previous comment - that can be not backward compatible in terms of a rolling cluster upgrades. With that different cluster nodes may run different versions, say cluster is now on 2.8 and user wants to do rolling upgrade to 2.11 (some general documentation on this).
In such case query may be serialized at 2.8 node (without new field at all) and deserialized an a 2.11 node. If we just try to read the boolean there will be a runtime exception. We need to check minimal supported version before even reading boolean flag.
The reverse scenario is also possible: query serialized on 2.11 node and read on 2.8 node, in such case we shouldn't write to the stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is newly introduced in 2.11. No issue with backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, BWC is not an issue as it's in new class, for others we can take care of them in next PRs
* add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00)
) * add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00) Co-authored-by: zhichao-aws <[email protected]>
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-main main
# Navigate to the new working tree
cd .worktrees/backport-main
# Create a new branch
git switch --create backport/backport-438-to-main
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 51e6c00770d27fb4eabc20c38bdeff23c5c45997
# Push it to GitHub
git push --set-upstream origin backport/backport-438-to-main
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-main Then, create a pull request where the |
…ch-project#438) * add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00)
…l_sparse query (#438) (#479) * [bug fix] Fix async actions are left in neural_sparse query (#438) * add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00) * rm max_token_score Signed-off-by: zhichao-aws <[email protected]> * add changelog Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]>
…l_sparse query (opensearch-project#438) (opensearch-project#479) * [bug fix] Fix async actions are left in neural_sparse query (opensearch-project#438) * add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00) * rm max_token_score Signed-off-by: zhichao-aws <[email protected]> * add changelog Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]>
…l_sparse query (opensearch-project#438) (opensearch-project#479) * [bug fix] Fix async actions are left in neural_sparse query (opensearch-project#438) * add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00) * rm max_token_score Signed-off-by: zhichao-aws <[email protected]> * add changelog Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]>
* Handle case with nested list of objects Signed-off-by: Gopala-Krishna.Char <[email protected]> * fix validateEmbeddingsFieldValues Method Signed-off-by: Gopala-Krishna.Char <[email protected]> * spotless formatting Signed-off-by: Gopala-Krishna.Char <[email protected]> * Onboard jenkins prod docker images on github actions (#483) Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Update dependency org.json:json to v20231013 (#481) Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com> Signed-off-by: Gopala-Krishna.Char <[email protected]> * [Backport main manually][bug fix] Fix async actions are left in neural_sparse query (#438) (#479) * [bug fix] Fix async actions are left in neural_sparse query (#438) * add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00) * rm max_token_score Signed-off-by: zhichao-aws <[email protected]> * add changelog Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Fixed exception for case when Hybrid query being wrapped into bool query (#490) * Adding null check for case when hybrid query wrapped into bool query Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Fixed Hybrid query for cases when it's wrapped into other compound queries (#498) * Fixed nested field case Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Added the github action to copy the attached issues label to PR. (#504) Signed-off-by: Navneet Verma <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Added support for jdk-21 (#500) * Added support for jdk-21 Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Add unit tests + small fixes Signed-off-by: krishy91 <[email protected]> * fix indentation Signed-off-by: krishy91 <[email protected]> * remove unused code + add 2nd level nesting test Signed-off-by: krishy91 <[email protected]> * add integration test for list of nested objects Signed-off-by: krishy91 <[email protected]> --------- Signed-off-by: Gopala-Krishna.Char <[email protected]> Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Navneet Verma <[email protected]> Signed-off-by: krishy91 <[email protected]> Co-authored-by: Gopala-Krishna.Char <[email protected]> Co-authored-by: Peter Zhu <[email protected]> Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com> Co-authored-by: zhichao-aws <[email protected]> Co-authored-by: Martin Gaievski <[email protected]> Co-authored-by: Navneet Verma <[email protected]>
* Handle case with nested list of objects Signed-off-by: Gopala-Krishna.Char <[email protected]> * fix validateEmbeddingsFieldValues Method Signed-off-by: Gopala-Krishna.Char <[email protected]> * spotless formatting Signed-off-by: Gopala-Krishna.Char <[email protected]> * Onboard jenkins prod docker images on github actions (#483) Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Update dependency org.json:json to v20231013 (#481) Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com> Signed-off-by: Gopala-Krishna.Char <[email protected]> * [Backport main manually][bug fix] Fix async actions are left in neural_sparse query (#438) (#479) * [bug fix] Fix async actions are left in neural_sparse query (#438) * add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00) * rm max_token_score Signed-off-by: zhichao-aws <[email protected]> * add changelog Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Fixed exception for case when Hybrid query being wrapped into bool query (#490) * Adding null check for case when hybrid query wrapped into bool query Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Fixed Hybrid query for cases when it's wrapped into other compound queries (#498) * Fixed nested field case Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Added the github action to copy the attached issues label to PR. (#504) Signed-off-by: Navneet Verma <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Added support for jdk-21 (#500) * Added support for jdk-21 Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Add unit tests + small fixes Signed-off-by: krishy91 <[email protected]> * fix indentation Signed-off-by: krishy91 <[email protected]> * remove unused code + add 2nd level nesting test Signed-off-by: krishy91 <[email protected]> * add integration test for list of nested objects Signed-off-by: krishy91 <[email protected]> --------- Signed-off-by: Gopala-Krishna.Char <[email protected]> Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Navneet Verma <[email protected]> Signed-off-by: krishy91 <[email protected]> Co-authored-by: Gopala-Krishna.Char <[email protected]> Co-authored-by: Peter Zhu <[email protected]> Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com> Co-authored-by: zhichao-aws <[email protected]> Co-authored-by: Martin Gaievski <[email protected]> Co-authored-by: Navneet Verma <[email protected]> (cherry picked from commit ea49d3c)
* Handle case with nested list of objects Signed-off-by: Gopala-Krishna.Char <[email protected]> * fix validateEmbeddingsFieldValues Method Signed-off-by: Gopala-Krishna.Char <[email protected]> * spotless formatting Signed-off-by: Gopala-Krishna.Char <[email protected]> * Onboard jenkins prod docker images on github actions (#483) Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Update dependency org.json:json to v20231013 (#481) Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com> Signed-off-by: Gopala-Krishna.Char <[email protected]> * [Backport main manually][bug fix] Fix async actions are left in neural_sparse query (#438) (#479) * [bug fix] Fix async actions are left in neural_sparse query (#438) * add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00) * rm max_token_score Signed-off-by: zhichao-aws <[email protected]> * add changelog Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Fixed exception for case when Hybrid query being wrapped into bool query (#490) * Adding null check for case when hybrid query wrapped into bool query Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Fixed Hybrid query for cases when it's wrapped into other compound queries (#498) * Fixed nested field case Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Added the github action to copy the attached issues label to PR. (#504) Signed-off-by: Navneet Verma <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Added support for jdk-21 (#500) * Added support for jdk-21 Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Add unit tests + small fixes Signed-off-by: krishy91 <[email protected]> * fix indentation Signed-off-by: krishy91 <[email protected]> * remove unused code + add 2nd level nesting test Signed-off-by: krishy91 <[email protected]> * add integration test for list of nested objects Signed-off-by: krishy91 <[email protected]> --------- Signed-off-by: Gopala-Krishna.Char <[email protected]> Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Navneet Verma <[email protected]> Signed-off-by: krishy91 <[email protected]> Co-authored-by: Gopala-Krishna.Char <[email protected]> Co-authored-by: Peter Zhu <[email protected]> Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com> Co-authored-by: zhichao-aws <[email protected]> Co-authored-by: Martin Gaievski <[email protected]> Co-authored-by: Navneet Verma <[email protected]> (cherry picked from commit ea49d3c) Co-authored-by: Gopala-Krishna Char <[email protected]>
* Handle case with nested list of objects Signed-off-by: Gopala-Krishna.Char <[email protected]> * fix validateEmbeddingsFieldValues Method Signed-off-by: Gopala-Krishna.Char <[email protected]> * spotless formatting Signed-off-by: Gopala-Krishna.Char <[email protected]> * Onboard jenkins prod docker images on github actions (opensearch-project#483) Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Update dependency org.json:json to v20231013 (opensearch-project#481) Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com> Signed-off-by: Gopala-Krishna.Char <[email protected]> * [Backport main manually][bug fix] Fix async actions are left in neural_sparse query (opensearch-project#438) (opensearch-project#479) * [bug fix] Fix async actions are left in neural_sparse query (opensearch-project#438) * add serialization and deserialization Signed-off-by: zhichao-aws <[email protected]> * hash, equals. + UT Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> * add test Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> (cherry picked from commit 51e6c00) * rm max_token_score Signed-off-by: zhichao-aws <[email protected]> * add changelog Signed-off-by: zhichao-aws <[email protected]> * tidy Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Fixed exception for case when Hybrid query being wrapped into bool query (opensearch-project#490) * Adding null check for case when hybrid query wrapped into bool query Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Fixed Hybrid query for cases when it's wrapped into other compound queries (opensearch-project#498) * Fixed nested field case Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Added the github action to copy the attached issues label to PR. (opensearch-project#504) Signed-off-by: Navneet Verma <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Added support for jdk-21 (opensearch-project#500) * Added support for jdk-21 Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Gopala-Krishna.Char <[email protected]> * Add unit tests + small fixes Signed-off-by: krishy91 <[email protected]> * fix indentation Signed-off-by: krishy91 <[email protected]> * remove unused code + add 2nd level nesting test Signed-off-by: krishy91 <[email protected]> * add integration test for list of nested objects Signed-off-by: krishy91 <[email protected]> --------- Signed-off-by: Gopala-Krishna.Char <[email protected]> Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: Martin Gaievski <[email protected]> Signed-off-by: Navneet Verma <[email protected]> Signed-off-by: krishy91 <[email protected]> Co-authored-by: Gopala-Krishna.Char <[email protected]> Co-authored-by: Peter Zhu <[email protected]> Co-authored-by: mend-for-github-com[bot] <50673670+mend-for-github-com[bot]@users.noreply.github.com> Co-authored-by: zhichao-aws <[email protected]> Co-authored-by: Martin Gaievski <[email protected]> Co-authored-by: Navneet Verma <[email protected]> Signed-off-by: yuye-aws <[email protected]>
Description
The bug exists in multi-nodes and multi-shards environment. For neural_search query, the cluster will throw error "async actions are left".
The search action contains 2 phase, query and fetch. In multi nodes & multi shards case, nodes will finish the query phase normally. But there will be a serialization and deserialization at the start of fetch shard phase, and after deserialization the doRewrite method of constructed QueryBuilder(i.e. NeuralSparseQueryBuilder) will be called. However for this rewrite the QueryBuilder can not have async action otherwise an exception will be thrown.
In our current implementation, the model inference result is not included in the serialization/deserialization process, and it will register an async action when rewritten. And this will break the search.
Add queryTokensSupplier to the process of serialization/deserialization, as well as doEquals and doHashCode
Issues Resolved
[List any issues this PR will resolve]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.