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

*: pull in fixes #65

Merged
merged 2 commits into from
Aug 2, 2023
Merged

*: pull in fixes #65

merged 2 commits into from
Aug 2, 2023

Conversation

GiedriusS
Copy link
Collaborator

Pull in data race fixes while I work on repro tests.

GiedriusS and others added 2 commits August 2, 2023 09:54
The matchers slice is now sorted in each call but that introduces a data
race because the slice is shared between all calls. Do the sorting once
on the outermost function.

Signed-off-by: Giedrius Statkevičius <[email protected]>
Comment on lines +968 to +978
sort.Slice(matchers, func(i, j int) bool {
if matchers[i].Type == matchers[j].Type {
if matchers[i].Name == matchers[j].Name {
return matchers[i].Value < matchers[j].Value
}
return matchers[i].Name < matchers[j].Name
}
return matchers[i].Type < matchers[j].Type
})

return matchers
Copy link

Choose a reason for hiding this comment

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

nit: could reduce nesting by:

sort.Slice(matchers, func(i, j int) bool {
   if matchers[i].Type != matchers[j].Type {
      return matchers[i].Type < matchers[j].Type
   }
			
   if matchers[i].Name == matchers[j].Name {
      return matchers[i].Value < matchers[j].Value
   }

   return matchers[i].Name < matchers[j].Name
})

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the original PR I copied/pasted the same logic thanos-io#6575 so I'd prefer to keep the same to reduce discrepancy 😄

Copy link

Choose a reason for hiding this comment

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

You could update both PR's 😏 😄

@GiedriusS GiedriusS merged commit 78f55b3 into 0.32.0+vinted Aug 2, 2023
@GiedriusS GiedriusS deleted the 0320006fixes branch August 2, 2023 08:14
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.

5 participants