-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: fully clean up partially opened TSI #23430
Conversation
When one partition in a TSI fails to open, all previously opened partitions should be cleaned up, and remaining partitions should not be opened closes #23427
f, err := os.Open(path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer f.Close() | ||
defer errors2.Capture(&err, f.Close)() |
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.
👍
if err := <-errC; err != nil { | ||
return err | ||
} | ||
g := new(errgroup.Group) |
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.
I love the errgroup
, we should do more of that - see also https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/
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.
I don't fully agree (edit: with the linked article) but it is nice to use the pattern where it fits.
tsdb/index/tsi1/index.go
Outdated
@@ -277,33 +278,21 @@ func (i *Index) Open() error { | |||
i.partitions[j] = p | |||
} | |||
|
|||
defer i.cleanUpFail(&rErr) |
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.
I think we want to defer this only after the Wait
on errGroup - otherwise we could accidentally add a return and run cleanUpFail
concurrently with the partition opening, which would be bad.
As I understand it, the partition type assumes Close
is never called concurrently with Open
.
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.
Fix pushed.
When one partition in a TSI fails to open, all previously opened partitions should be cleaned up, and remaining partitions should not be opened closes influxdata#23427
When one partition in a TSI fails to open, all previously opened partitions should be cleaned up, and remaining partitions should not be opened closes influxdata#23427
When one partition in a TSI fails to open,
all previously opened partitions should be cleaned up, and remaining partitions should not be opened
closes #23427