Ingester lock tweaks to minimize headblock locking during search#3328
Merged
mdisibio merged 9 commits intografana:mainfrom Jan 31, 2024
Merged
Ingester lock tweaks to minimize headblock locking during search#3328mdisibio merged 9 commits intografana:mainfrom
mdisibio merged 9 commits intografana:mainfrom
Conversation
Contributor
Author
|
Putting back to draft because allocating the channel size based on the limit doesn't work for cases where the limit is large (1,000,000+) |
zalegrala
reviewed
Jan 26, 2024
| if err != nil { | ||
| return fmt.Errorf("error opening file %s: %w", page.path, err) | ||
| } | ||
| defer file.Close() |
Contributor
There was a problem hiding this comment.
Is the defer inside the loop enough, or do we want to close it out each iteration through blockFlushes?
Contributor
Author
There was a problem hiding this comment.
That's correct, it's inside the loop and all of them get closed at the end, which is not optimal. This func and several others are all following the same pattern, and I was aiming to have minimum changes necessary. But happy to make larger changes and defer as expected if we want.
joe-elliott
reviewed
Jan 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
We have seen occasional high read latencies on ingesters where tag lookups and searches take 20+ seconds instead of the typical few. Investigation showed that it is contention on the block mutexes, and specifically due to the design of
instance.SearchandSearchResults. Instead of searching and releasing the headblock asap, the lock was held until after also acquiring a lock on the rest of the blocks and beginning to read fromSearchResults. High latency occurs when read/write access to the mutexes stack up, such that it might have to wait for a current search to finish (releasing read lock), then a block flush (write lock), then acquiring read lock again.This moves away from
SearchResultsand the channel-based flow to a simpler setup like the other endpoints. Since this was the only usage ofSearchResultsthis seems better than trying to patch it (again).Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]