-
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(tsi): close series id iterator after merging #19936
Conversation
96465f4
to
9ae2bbe
Compare
9ae2bbe
to
0be081b
Compare
@danxmoran can you review this PR ? |
0be081b
to
38861cf
Compare
@@ -557,9 +557,10 @@ func IntersectSeriesIDIterators(itr0, itr1 SeriesIDIterator) SeriesIDIterator { | |||
|
|||
// Create series id set, if available. | |||
if a := NewSeriesIDSetIterators([]SeriesIDIterator{itr0, itr1}); a != nil { | |||
ss := a[0].SeriesIDSet().And(a[1].SeriesIDSet()) |
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.
Does a[0] == itr0
and a[1] == itr1
here? If so, could we add a comment saying so? I think it'll make it more obvious why the Close()
calls have to happen after this
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 added comments. please check if it matches your suggestion.
@@ -646,10 +647,10 @@ func UnionSeriesIDIterators(itr0, itr1 SeriesIDIterator) SeriesIDIterator { | |||
|
|||
// Create series id set, if available. | |||
if a := NewSeriesIDSetIterators([]SeriesIDIterator{itr0, itr1}); a != nil { | |||
itr0.Close() | |||
itr1.Close() | |||
ss := NewSeriesIDSet() | |||
ss.Merge(a[0].SeriesIDSet(), a[1].SeriesIDSet()) |
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.
Same comment / request as above
@@ -733,9 +734,10 @@ func DifferenceSeriesIDIterators(itr0, itr1 SeriesIDIterator) SeriesIDIterator { | |||
|
|||
// Create series id set, if available. | |||
if a := NewSeriesIDSetIterators([]SeriesIDIterator{itr0, itr1}); a != nil { | |||
ss := a[0].SeriesIDSet().AndNot(a[1].SeriesIDSet()) |
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.
Same comment / request as above
This use-after-free bug may lead to segfault. The iterators that have reference to the underlying index files were closed too early while the bitmaps were still used afterwards. If a compaction occurs concurrently and removes the index files, it would result in accessing unmap'd memory address.
38861cf
to
ee2439b
Compare
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 again! I'll handle wrangling the CI / changelog from here
This use-after-free bug may lead to segfault. The iterators that have
reference to the underlying index files were closed too early while
the bitmaps were still used afterwards. If a compaction occurs
concurrently and removes the index files, it would result in accessing
unmap'd memory address.