-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
Signed-off-by: Ben Ye <yb532204897@gmail.com>
Signed-off-by: Ben Ye <yb532204897@gmail.com>
Generally looking good. Some other pair of eyes would be good, as I'm not too familiar with this part. |
There was a problem hiding this 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
pkg/queryfrontend/labels_codec.go
Outdated
i := 0 | ||
var resp queryrange.Response | ||
for _, response := range responses { | ||
if len(response.(*ThanosSeriesResponse).Data) > 0 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 (:
There was a problem hiding this comment.
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>
Hi, please take a look again. @bwplotka @metalmatze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks 💪
We need changelog but we can add on release PR |
when release v0.17.2 ? i meet this bug, so had to go back v0.16.0. |
* 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>
* 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>
Signed-off-by: Ben Ye yb532204897@gmail.com
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