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 race on the string interning #6408

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

alanprot
Copy link
Member

@alanprot alanprot commented Dec 9, 2024

What this PR does:
Fix Race when the -ingester.labels-string-interning-enabled experimental feature is enabled.

The race happens as tsdb calls the PostCreation outside the lock (see this) but after the series is already added on the s.hashes hash. With this, this series is already returned on the GetByHash method and so, we may race with the interning.

This change is proposing intern the strings using a LRU cache and so we can stop managing the release of the strings. The LRU ttl is set to be similar to the range blocks interval and so, we should not keep strings in the heap for more time than needed.

Which issue(s) this PR fixes:
Fixes #

Checklist

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

@alanprot alanprot force-pushed the race-string-intern branch 2 times, most recently from 0d1d004 to bd6b5df Compare December 9, 2024 22:32
@alanprot alanprot marked this pull request as ready for review December 9, 2024 22:33
@alanprot alanprot requested a review from yeya24 December 9, 2024 22:47
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@alanprot alanprot merged commit fb783a7 into cortexproject:master Dec 10, 2024
16 checks passed
@alanprot alanprot deleted the race-string-intern branch December 10, 2024 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants