Skip to content

fix(segment): guard min_should estimator edge cases#8217

Merged
timvisee merged 1 commit into
qdrant:devfrom
krapcys1-maker:fix-7974-clean
Feb 25, 2026
Merged

fix(segment): guard min_should estimator edge cases#8217
timvisee merged 1 commit into
qdrant:devfrom
krapcys1-maker:fix-7974-clean

Conversation

@krapcys1-maker

@krapcys1-maker krapcys1-maker commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #7974

Summary

This PR prevents a panic (alloc::raw_vec::capacity_overflow) in
segment::index::query_estimator::combine_min_should_estimations when
min_should.min_count is an edge value.

What changed

  • Add guards in combine_min_should_estimations:
    • min_count == 0CardinalityEstimation::exact(total) (trivially satisfied)
    • min_count > estimations.len()CardinalityEstimation::exact(0) (unsatisfiable)
  • Add 2 regression unit tests covering both cases.

Why

Without these guards, malformed/edge inputs can reach combinations(min_count) and
trigger pathological allocation, leading to a server panic instead of a safe estimate.

Local verification

cargo test -p segment

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --workspace --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Comment thread lib/segment/src/index/query_estimator.rs Outdated
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@qdrant qdrant deleted a comment from coderabbitai Bot Feb 25, 2026

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this makes sense!

@timvisee timvisee requested a review from generall February 25, 2026 09:10
@timvisee timvisee merged commit 2006757 into qdrant:dev Feb 25, 2026
16 checks passed
@krapcys1-maker krapcys1-maker deleted the fix-7974-clean branch February 25, 2026 10:09
generall pushed a commit that referenced this pull request Mar 26, 2026
Co-authored-by: local-user <local-user@local>
KShivendu pushed a commit that referenced this pull request Mar 30, 2026
Co-authored-by: local-user <local-user@local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants