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

Prevent data race by using xxhash instance as a local variable #1387

Merged
merged 3 commits into from
Apr 14, 2022

Conversation

bikashmishra100
Copy link
Contributor

What this PR does:
A shared instance of xxhash causes a data race and crash in the ingester. This PR fixes by converting the shared instance to a local variable.

Which issue(s) this PR fixes:
Fixes #1384

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@CLAassistant
Copy link

CLAassistant commented Apr 14, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

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

PR is looking good. Thanks for the contribution!

If you can add a bugfix changelog entry we will merge.

@bikashmishra100
Copy link
Contributor Author

Thank you. Added the change log entry.

a.hash.Reset()
_, _ = a.hash.Write(id)
hash := a.hash.Sum64()
hasher := xxhash.New()
Copy link
Contributor

Choose a reason for hiding this comment

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

fwiw - I think we could keep the static hash for writes and just alloc a new one for reads.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, that's fair. it's a small improvement, but this code is called constantly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the code

Copy link
Member

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

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

Nice fix! Thanks

@joe-elliott joe-elliott merged commit 288c32c into grafana:main Apr 14, 2022
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.

Shared xxhash instance in the appender causes a data race and crashes the ingester
4 participants