Fix duplicate hybrid search result subscription#49831
Open
arnabnandy7 wants to merge 2 commits into
Open
Conversation
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
Contributor
|
Thank you for your contribution @arnabnandy7! We will review the pull request and get back to you soon. |
|
Azure Pipelines: Successfully started running 2 pipeline(s). 33 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an intermittent IndexOutOfBoundsException in cross-partition hybrid search queries (ORDER BY RANK RRF(...)) by ensuring the coalesced component-query results are materialized once and shared across downstream reactive branches, preventing mismatched rank/score computations caused by duplicate subscriptions.
Changes:
- Cached the coalesced-and-sorted hybrid search result
Monoto prevent duplicate re-execution and inconsistent result sizing across reactive branches. - Added a CHANGELOG entry documenting the bug fix and linking to the tracked issue.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/HybridSearchDocumentQueryExecutionContext.java | Adds .cache() to the coalesced-and-sorted results Mono so rank and RRF computations consume the same materialized result set. |
| sdk/cosmos/azure-cosmos/CHANGELOG.md | Documents the hybrid search cross-partition IndexOutOfBoundsException fix and references Issue #49823. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes an intermittent
IndexOutOfBoundsExceptionwhen executing cross-partition hybrid search queries usingORDER BY RANK RRF(...).The coalesced component-query results were consumed by two reactive branches. Because the result
Monowas cold, each branch independently re-executed the cross-partition query pipeline and could receive a differently sized result list. The ranks calculated from one result set could then be applied to another, causing the exception.This change caches the coalesced result
Mono, ensuring rank calculation and RRF score calculation operate on the same materialized results.Fixes #49823.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines
The
azure-cosmosmodule was successfully compiled for both the Java baseline and module-path build. No new automated test was added because reproducing the original failure requires nondeterministic timing differences between duplicate subscriptions to a live, cross-partition query. Existing hybrid-search integration tests continue to cover RRF query execution.