Skip to content
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

222 fix query #247

Merged
merged 2 commits into from
Oct 7, 2021
Merged

222 fix query #247

merged 2 commits into from
Oct 7, 2021

Conversation

thorfour
Copy link
Contributor

@thorfour thorfour commented Oct 6, 2021

Addresses the error in #222 by correctly handling matchers that produce a empty bitmap

Adds unit test to catch this behavior.

@@ -367,14 +367,14 @@ func (q *HeadQuerier) Select(hints *SelectHints, ms ...*labels.Matcher) SeriesSe

ir, err := q.head.Index()
if err != nil {
return nil
return &SliceSeriesSet{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We blindly assume that Select doesn't return nil, so I set these error cases to return an empty set instead.

pkg/storage/querier.go Outdated Show resolved Hide resolved
@thorfour thorfour closed this Oct 6, 2021
@thorfour thorfour reopened this Oct 6, 2021
Subsequent And operations from postingsForMatcher
can cause the bitmap to be empty, but doesn't mean it should be set to
the next result.

ex:
    A: [1,2]
    B: [maxuint64]
    C: [1,2]

    should result in an empty array

    however if they are applied in order with the previous logic of

    if bitmap.IsEmpty() {
        bitmap = bm
    } else {
        bitmap.And(bm)
    }

    We'll see

        bitmap = A [1,2]
        bitmap = A & B = []
        bitmap = C = [1,2]

    which will return incorrect postings
@thorfour thorfour merged commit aa81251 into main Oct 7, 2021
@thorfour thorfour deleted the 222-fix-query branch October 7, 2021 01:42
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.

1 participant