-
Notifications
You must be signed in to change notification settings - Fork 834
Refactored TSDB opening concurrency at startup #3393
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
Refactored TSDB opening concurrency at startup #3393
Conversation
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 still bit more complicated than I would prefer. Suggestion to use errgroup
would give us 1) handling of error (no need for errs
and errsMx
), 2) cancellation of context (right now if opening of one TSDB fails, other will still be tried), 3) simplified waiting (no need for wg
).
When using errgroup
, I'd suggest to spawn dir-walker as another goroutine, which can return its own error. Dir walker should react on group context cancellation, and by closing channel via defer, it will let tsdb-opening goroutines to stop as well.
Currently this code can return multiple errors – using errgroup
will only return first one [I don't think this matters too much], but we can still log them all – as it is now.
pkg/ingester/ingester_v2.go
Outdated
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.
By returning here, we lose a consumer of queue
channel, which can lead to blocking of dir walker, when it tries to send another item to the channel.
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.
Uh good point!
0e92126
to
492dab6
Compare
Thanks @pstibrany for your thoughtful code review. Could you take another look, please? |
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.
LGTM, Thanks!
pkg/ingester/ingester_v2.go
Outdated
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.
Nit: I think this is unnecessary since dir-walker reacts on groupCtx.Err()
and closes queue
.
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
492dab6
to
1b0e31d
Compare
What this PR does:
This is an internal refactoring with no user impact. In the PR #3354 I received the feedback:
In this PR I'm addressing this feedback splitting the logic between the "scan" and the "opening".
Which issue(s) this PR fixes:
N/A
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]