Skip to content

Conversation

@weiliu1031
Copy link
Contributor

@weiliu1031 weiliu1031 commented Oct 16, 2025

issue: #44909

When requery optimization is enabled, search results contain IDs
but empty FieldsData. During reduce/rerank operations, if the
first shard has empty FieldsData while others have data,
PrepareResultFieldData initializes an empty array, causing
AppendFieldData to panic when accessing array indices.

Changes:

  • Find first non-empty FieldsData as template in 3 functions:
    reduceAdvanceGroupBy, reduceSearchResultDataWithGroupBy,
    reduceSearchResultDataNoGroupBy
  • Add length check before 2 AppendFieldData calls in reduce
    functions to prevent panic
  • Improve newRerankOutputs to find first non-empty fieldData
    using len(FieldsData) check instead of GetSizeOfIDs
  • Add length check in appendResult before AppendFieldData
  • Add comprehensive unit tests for empty and partial empty
    FieldsData scenarios in both reduce and rerank functions

This fix handles both pure requery (all empty) and mixed
scenarios (some empty, some with data) without breaking normal
search flow. The key improvement is checking FieldsData length
directly rather than IDs, as requery may have IDs but empty
FieldsData.

@sre-ci-robot sre-ci-robot added the size/L Denotes a PR that changes 100-499 lines. label Oct 16, 2025
@mergify mergify bot added dco-passed DCO check passed. kind/bug Issues or changes related a bug labels Oct 16, 2025
@sre-ci-robot
Copy link
Contributor

[ci-v2-notice]
Notice: We are gradually rolling out the new ci-v2 system.

  • Legacy CI jobs remain unaffected, you can just ignore ci-v2 if you don't want to run it.
  • Additional "ci-v2/*" checkers will run for this PR to ensure the new ci-v2 system is working as expected.
  • For tests that exist in both v1 and v2, passing in either system is considered PASS.

To rerun ci-v2 checks, comment with:

  • /ci-rerun-code-check // for ci-v2/code-check
  • /ci-rerun-build // for ci-v2/build
  • /ci-rerun-ut-integration // for ci-v2/ut-integration
  • /ci-rerun-ut-go // for ci-v2/ut-go
  • /ci-rerun-ut-cpp // for ci-v2/ut-cpp
  • /ci-rerun-ut // for all ci-v2/ut-integration, ci-v2/ut-go, ci-v2/ut-cpp

If you have any questions or requests, please contact @zhikunyao.

weiliu1031 added a commit to weiliu1031/milvus that referenced this pull request Oct 16, 2025
issue: milvus-io#44909
pr: milvus-io#44917
This change adds validation to filter out empty search results
before reranking operations in both regular and advanced search
scenarios.

When QueryNode returns empty search results (with no IDs or
fields), the rerank process would panic when trying to access
result data. This happens in hybrid search scenarios where some
sub-requests may return empty results.

Changes include:
- Add empty result filtering in reduceResults method
- Add empty result filtering in PostExecute for advanced search
- Add empty result filtering in all reduce utility functions
  (reduceAdvanceGroupBY, reduceSearchResultDataWithGroupBy,
   reduceSearchResultDataNoGroupBy, rankSearchResultDataByGroup,
   rankSearchResultDataByPk)
- Add unit tests to verify empty result handling

This fix ensures empty results are filtered out before being
passed to ranking functions, preventing the panic.

Signed-off-by: Wei Liu <[email protected]>
@mergify
Copy link
Contributor

mergify bot commented Oct 16, 2025

@weiliu1031 cpu-e2e job failed, comment /run-cpu-e2e can trigger the job again.

@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.94%. Comparing base (a3a28a4) to head (7bade09).
⚠️ Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
internal/proxy/search_reduce_util.go 57.14% 6 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #44917       +/-   ##
===========================================
- Coverage   83.90%   76.94%    -6.97%     
===========================================
  Files         507     1830     +1323     
  Lines       77920   285194   +207274     
===========================================
+ Hits        65378   219431   +154053     
- Misses      12542    58562    +46020     
- Partials        0     7201     +7201     
Components Coverage Δ
Client 78.03% <ø> (∅)
Core 83.90% <ø> (ø)
Go 75.03% <75.00%> (∅)
Files with missing lines Coverage Δ
internal/util/function/rerank/util.go 84.26% <100.00%> (ø)
internal/proxy/search_reduce_util.go 82.16% <57.14%> (ø)

... and 1321 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify
Copy link
Contributor

mergify bot commented Oct 16, 2025

@weiliu1031 go-sdk check failed, comment rerun go-sdk can trigger the job again.

@weiliu1031 weiliu1031 force-pushed the fix_rerank_panic branch 3 times, most recently from 8dae031 to 4e8fb8c Compare October 17, 2025 06:38
weiliu1031 added a commit to weiliu1031/milvus that referenced this pull request Oct 17, 2025
issue: milvus-io#44909
pr: milvus-io#44917
This change adds validation to filter out empty search results
before reranking operations in both regular and advanced search
scenarios.

When QueryNode returns empty search results (with no IDs or
fields), the rerank process would panic when trying to access
result data. This happens in hybrid search scenarios where some
sub-requests may return empty results.

Changes include:
- Add empty result filtering in reduceResults method
- Add empty result filtering in PostExecute for advanced search
- Add empty result filtering in all reduce utility functions
  (reduceAdvanceGroupBY, reduceSearchResultDataWithGroupBy,
   reduceSearchResultDataNoGroupBy, rankSearchResultDataByGroup,
   rankSearchResultDataByPk)
- Add unit tests to verify empty result handling

This fix ensures empty results are filtered out before being
passed to ranking functions, preventing the panic.

Signed-off-by: Wei Liu <[email protected]>
@weiliu1031 weiliu1031 changed the title fix: Filter empty search results to prevent rerank panic fix: fix: Handle empty FieldsData in reduce/rerank for requery scenario Oct 20, 2025
@weiliu1031 weiliu1031 changed the title fix: fix: Handle empty FieldsData in reduce/rerank for requery scenario fix: Handle empty FieldsData in reduce/rerank for requery scenario Oct 20, 2025
@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2025

@weiliu1031 cpu-e2e job failed, comment /run-cpu-e2e can trigger the job again.

@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2025

@weiliu1031 go-sdk check failed, comment rerun go-sdk can trigger the job again.

issue: milvus-io#44909

When requery optimization is enabled, search results contain IDs
but empty FieldsData. During reduce/rerank operations, if the
first shard has empty FieldsData while others have data,
PrepareResultFieldData initializes an empty array, causing
AppendFieldData to panic when accessing array indices.

Changes:
- Find first non-empty FieldsData as template in 3 functions:
  reduceAdvanceGroupBy, reduceSearchResultDataWithGroupBy,
  reduceSearchResultDataNoGroupBy
- Add length check before 2 AppendFieldData calls in reduce
  functions to prevent panic
- Improve newRerankOutputs to find first non-empty fieldData
  using len(FieldsData) check instead of GetSizeOfIDs
- Add length check in appendResult before AppendFieldData
- Add comprehensive unit tests for empty and partial empty
  FieldsData scenarios in both reduce and rerank functions

This fix handles both pure requery (all empty) and mixed
scenarios (some empty, some with data) without breaking normal
search flow. The key improvement is checking FieldsData length
directly rather than IDs, as requery may have IDs but empty
FieldsData.

Signed-off-by: Wei Liu <[email protected]>
Copy link
Contributor

@congqixia congqixia left a comment

Choose a reason for hiding this comment

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

/lgtm

@sre-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: congqixia, weiliu1031

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot sre-ci-robot merged commit 9dddc38 into milvus-io:master Oct 21, 2025
15 of 18 checks passed
sre-ci-robot pushed a commit that referenced this pull request Oct 21, 2025
…rio (#44919)

issue: #44909
pr: #44917
When requery optimization is enabled, search results contain IDs but
empty FieldsData. During reduce/rerank operations, if the first shard
has empty FieldsData while others have data, PrepareResultFieldData
initializes an empty array, causing AppendFieldData to panic when
accessing array indices.

Changes:
- Find first non-empty FieldsData as template in 5 functions:
  reduceAdvanceGroupBY, reduceSearchResultDataWithGroupBy,
  reduceSearchResultDataNoGroupBy, rankSearchResultDataByGroup,
  rankSearchResultDataByPk
- Add length check before 4 AppendFieldData calls to prevent panic
- Add unit tests for empty and partial empty FieldsData scenarios

This fix handles both pure requery (all empty) and mixed scenarios
(some empty, some with data) without breaking normal search flow.

Signed-off-by: Wei Liu <[email protected]>
weiliu1031 added a commit to weiliu1031/milvus that referenced this pull request Oct 21, 2025
…uery scenario (milvus-io#44919)

issue: milvus-io#44909
pr: milvus-io#44917
When requery optimization is enabled, search results contain IDs but
empty FieldsData. During reduce/rerank operations, if the first shard
has empty FieldsData while others have data, PrepareResultFieldData
initializes an empty array, causing AppendFieldData to panic when
accessing array indices.

Changes:
- Find first non-empty FieldsData as template in 5 functions:
  reduceAdvanceGroupBY, reduceSearchResultDataWithGroupBy,
  reduceSearchResultDataNoGroupBy, rankSearchResultDataByGroup,
  rankSearchResultDataByPk
- Add length check before 4 AppendFieldData calls to prevent panic
- Add unit tests for empty and partial empty FieldsData scenarios

This fix handles both pure requery (all empty) and mixed scenarios
(some empty, some with data) without breaking normal search flow.

Signed-off-by: Wei Liu <[email protected]>
sre-ci-robot pushed a commit that referenced this pull request Oct 21, 2025
…uery scenario (#44919) (#45016)

issue: #44909
pr: #44917
When requery optimization is enabled, search results contain IDs but
empty FieldsData. During reduce/rerank operations, if the first shard
has empty FieldsData while others have data, PrepareResultFieldData
initializes an empty array, causing AppendFieldData to panic when
accessing array indices.

Changes:
- Find first non-empty FieldsData as template in 5 functions:
reduceAdvanceGroupBY, reduceSearchResultDataWithGroupBy,
reduceSearchResultDataNoGroupBy, rankSearchResultDataByGroup,
rankSearchResultDataByPk
- Add length check before 4 AppendFieldData calls to prevent panic
- Add unit tests for empty and partial empty FieldsData scenarios

This fix handles both pure requery (all empty) and mixed scenarios (some
empty, some with data) without breaking normal search flow.

Signed-off-by: Wei Liu <[email protected]>
weiliu1031 added a commit to weiliu1031/milvus that referenced this pull request Oct 29, 2025
…ilvus-io#44917)

issue: milvus-io#44909

When requery optimization is enabled, search results contain IDs
but empty FieldsData. During reduce/rerank operations, if the
first shard has empty FieldsData while others have data,
PrepareResultFieldData initializes an empty array, causing
AppendFieldData to panic when accessing array indices.

Changes:
- Find first non-empty FieldsData as template in 3 functions:
  reduceAdvanceGroupBy, reduceSearchResultDataWithGroupBy,
  reduceSearchResultDataNoGroupBy
- Add length check before 2 AppendFieldData calls in reduce
  functions to prevent panic
- Improve newRerankOutputs to find first non-empty fieldData
  using len(FieldsData) check instead of GetSizeOfIDs
- Add length check in appendResult before AppendFieldData
- Add comprehensive unit tests for empty and partial empty
  FieldsData scenarios in both reduce and rerank functions

This fix handles both pure requery (all empty) and mixed
scenarios (some empty, some with data) without breaking normal
search flow. The key improvement is checking FieldsData length
directly rather than IDs, as requery may have IDs but empty
FieldsData.

Signed-off-by: Wei Liu <[email protected]>
sre-ci-robot pushed a commit that referenced this pull request Oct 29, 2025
…44917) (#45137)

issue: #44909
pr: #44917

When requery optimization is enabled, search results contain IDs but
empty FieldsData. During reduce/rerank operations, if the first shard
has empty FieldsData while others have data, PrepareResultFieldData
initializes an empty array, causing AppendFieldData to panic when
accessing array indices.

Changes:
- Find first non-empty FieldsData as template in 3 functions:
reduceAdvanceGroupBy, reduceSearchResultDataWithGroupBy,
reduceSearchResultDataNoGroupBy
- Add length check before 2 AppendFieldData calls in reduce functions to
prevent panic
- Improve newRerankOutputs to find first non-empty fieldData using
len(FieldsData) check instead of GetSizeOfIDs
- Add length check in appendResult before AppendFieldData
- Add comprehensive unit tests for empty and partial empty FieldsData
scenarios in both reduce and rerank functions

This fix handles both pure requery (all empty) and mixed scenarios (some
empty, some with data) without breaking normal search flow. The key
improvement is checking FieldsData length directly rather than IDs, as
requery may have IDs but empty FieldsData.

Signed-off-by: Wei Liu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved ci-passed dco-passed DCO check passed. kind/bug Issues or changes related a bug lgtm size/L Denotes a PR that changes 100-499 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants