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

fix index out of bound bug when comparing ZLabelSets #3520

Merged
merged 3 commits into from
Dec 3, 2020

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Nov 30, 2020

Signed-off-by: Ben Ye yb532204897@gmail.com

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Fixes #3515

The bug is originated from that I got the label pair length using Size() method, it is a stupid mistake 👎 because it doesn't return the number of label pairs.
Added one test case to ensure no panic for comparing the same label sets.
However, we deduplicate the series before sorting them so the case shouldn't happen. Still investigating the root cause and trying to reproduce this from the query frontend side.

Verification

Signed-off-by: Ben Ye <yb532204897@gmail.com>
Signed-off-by: Ben Ye <yb532204897@gmail.com>
@yeya24 yeya24 changed the title WIP: fix index out of bound bug when comparing ZLabelSets fix index out of bound bug when comparing ZLabelSets Dec 3, 2020
@metalmatze
Copy link
Contributor

Generally looking good. Some other pair of eyes would be good, as I'm not too familiar with this part.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks, but would be amazing to not have unrelated to fix changes in quick bug fix PR.

Since you have those, there are minor issues/suggestions for unrelated changes, otherwise LGTM

i := 0
var resp queryrange.Response
for _, response := range responses {
if len(response.(*ThanosSeriesResponse).Data) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I don't get this, why we cannot check this in loop below?

Copy link
Contributor Author

@yeya24 yeya24 Dec 3, 2020

Choose a reason for hiding this comment

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

Makes sense. As you mentioned I ll remove this change since it is unrelated and I ll fix them in next pr against master

@@ -111,7 +111,7 @@ func (c queryRangeCodec) DecodeRequest(_ context.Context, r *http.Request) (quer
result.ReplicaLabels = r.Form[queryv1.ReplicaLabelsParam]
}

result.StoreMatchers, err = parseMatchersParam(r.Form[queryv1.StoreMatcherParam])
result.StoreMatchers, err = parseMatchersParam(r.Form[queryv1.StoreMatcherParam], queryv1.StoreMatcherParam)
Copy link
Member

Choose a reason for hiding this comment

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

This is bad code smell - passing same information twice. Maybe we should pass just Form and matcherKey to param function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

@@ -307,7 +307,8 @@ func (z ZLabelSets) Less(i, j int) bool {
l := 0
r := 0
var result int
for l < z[i].Size() && r < z[j].Size() {
lenI, lenJ := len(z[i].Labels), len(z[j].Labels)
Copy link
Member

Choose a reason for hiding this comment

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

👍 (:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:(

Signed-off-by: Ben Ye <yb532204897@gmail.com>
@yeya24
Copy link
Contributor Author

yeya24 commented Dec 3, 2020

Hi, please take a look again. @bwplotka @metalmatze

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks 💪

@bwplotka
Copy link
Member

bwplotka commented Dec 3, 2020

We need changelog but we can add on release PR

@bwplotka bwplotka merged commit e3c175a into thanos-io:release-0.17 Dec 3, 2020
@yeya24 yeya24 deleted the release-0.17 branch December 3, 2020 16:30
@iyacontrol
Copy link
Contributor

when release v0.17.2 ? i meet this bug, so had to go back v0.16.0.

metalmatze pushed a commit to metalmatze/thanos that referenced this pull request Dec 9, 2020
* fix index out of bound bug when comparing ZLabelSets

Signed-off-by: Ben Ye <yb532204897@gmail.com>

* fix param parsing error message

Signed-off-by: Ben Ye <yb532204897@gmail.com>

* address comment feedbacks

Signed-off-by: Ben Ye <yb532204897@gmail.com>
bwplotka added a commit that referenced this pull request Dec 9, 2020
* Fix query frontend regression on release v0.17.0 (#3480)

* query-frontend: make POST-request to downstream url for labels and series api endpoints (#3444)

Signed-off-by: Alexander Tunik <2braven@gmail.com>

* remove default response cache config

Signed-off-by: Ben Ye <yb532204897@gmail.com>

* ensure order when merging multiple responses

Signed-off-by: Ben Ye <yb532204897@gmail.com>

Co-authored-by: Alexander Tunik <2braven@gmail.com>

* *: Set debug.SetPanicOnFault(true) so we can recover seg faults. (#3498)

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Prepare v0.17.1 release (#3505)

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* fix index out of bound bug when comparing ZLabelSets (#3520)

* fix index out of bound bug when comparing ZLabelSets

Signed-off-by: Ben Ye <yb532204897@gmail.com>

* fix param parsing error message

Signed-off-by: Ben Ye <yb532204897@gmail.com>

* address comment feedbacks

Signed-off-by: Ben Ye <yb532204897@gmail.com>

* compact: do not cleanup blocks on boot (#3532)

Do not cleanup blocks on boot because in some very bad cases there could
be thousands of blocks ready-to-be deleted and doing that makes Thanos
Compact exceed `initialDelaySeconds` on k8s.

Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>

* Prepare v0.17.2 (#3543)

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

* Properly rebase CHANGELOG.md after merging release-0.17

Signed-off-by: Matthias Loibl <mail@matthiasloibl.com>

Co-authored-by: Ben Ye <yb532204897@gmail.com>
Co-authored-by: Alexander Tunik <2braven@gmail.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Co-authored-by: Giedrius Statkevičius <giedriuswork@gmail.com>
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