-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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 memory leak in two_level_iterator #3718
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.
@miasantreble has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@siying PTAL my changes in TwoLevelIterator __dtor |
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 know about the TwoLevelIterator
changes, so am accepting the unused params part only (which could be a whole PR itself)
util/delete_scheduler_test.cc
Outdated
@@ -642,6 +642,8 @@ int main(int argc, char** argv) { | |||
|
|||
#else | |||
int main(int argc, char** argv) { | |||
(void) argc; |
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.
can we comment out never-used variables?
I changed the title from "fix memory leak and unused param errors" to more descriptive title of "fix memory leak in two_level_iterator" |
table/two_level_iterator.cc
Outdated
@@ -24,7 +24,11 @@ class TwoLevelIterator : public InternalIterator { | |||
explicit TwoLevelIterator(TwoLevelIteratorState* state, | |||
InternalIterator* first_level_iter); | |||
|
|||
virtual ~TwoLevelIterator() { delete state_; } | |||
virtual ~TwoLevelIterator() { | |||
first_level_iter_.DeleteIter(false); |
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.
what is the variable that is assigned to false? and why false?
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.
it's is_arena_mode
that dictates whether to call delete
or ~InternalIterator()
, see https://github.com/facebook/rocksdb/blob/master/table/iterator_wrapper.h#L45
I think by default it was false for both first and second level iter in the original code https://github.com/facebook/rocksdb/pull/3406/files#diff-5fed9b271c2846509d9ad683c2624f26
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.
- Can you put a comment beside the false value? something like
/* is_arena_mode */
- What if later someone uses TwoLevelIterator and passes a first_level_iterator is created using arena? Can we add some comments to NewTwoLevelIterator and NewSecondaryIterator to indicate the contract that the object should not have been created using arena.
@@ -1023,20 +1023,16 @@ class DbStressListener : public EventListener { | |||
column_families_(column_families) {} | |||
virtual ~DbStressListener() {} | |||
#ifndef ROCKSDB_LITE | |||
virtual void OnFlushCompleted(DB* db, const FlushJobInfo& info) override { | |||
assert(db); |
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.
instead of removing the assert, can we use unused attributed?
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.
@ajkr suggested these assert are useless since for db_stress they will always be true
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.
yeah it seemed strange to me that we're testing whether OnFlushCompleted
is passed the right arguments in our stress test, so I suggested deleting those checks rather than maintaining them.
why not using attribute((unused))? |
@maysamyabandeh the |
@miasantreble has updated the pull request. View: changes, changes since last import |
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.
@miasantreble has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Can you also add a comment about arena to table/two_level_iterator.h:25
|
@miasantreble has updated the pull request. View: changes, changes since last import |
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.
@miasantreble has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Seems like you strongly oppose against adding any clarification to NewSecondaryIterator. No problem. I can add it later after you land this. |
@maysamyabandeh No, I don't have problem with that, I missed the line number in your comment so I added in line 20, do you think that's ok or shall I move it to line 25? |
Thanks @miasantreble. Let me go ahead and land this as I am about concerned about the production services being affected by that. |
Summary: this PR fixes a few failed contbuild: 1. ASAN memory leak in Block::NewIterator (table/block.cc:429). the proper destruction of first_level_iter_ and second_level_iter_ of two_level_iterator.cc is missing from the code after the refactoring in #3406 2. various unused param errors introduced by #3662 3. updated comment for `ForceReleaseCachedEntry` to emphasize the use of `force_erase` flag. Closes #3718 Reviewed By: maysamyabandeh Differential Revision: D7621192 Pulled By: miasantreble fbshipit-source-id: 476c94264083a0730ded957c29de7807e4f5b146
Summary: this PR fixes a few failed contbuild: 1. ASAN memory leak in Block::NewIterator (table/block.cc:429). the proper destruction of first_level_iter_ and second_level_iter_ of two_level_iterator.cc is missing from the code after the refactoring in #3406 2. various unused param errors introduced by #3662 3. updated comment for `ForceReleaseCachedEntry` to emphasize the use of `force_erase` flag. Closes #3718 Reviewed By: maysamyabandeh Differential Revision: D7621192 Pulled By: miasantreble fbshipit-source-id: 476c94264083a0730ded957c29de7807e4f5b146
Summary: this PR fixes a few failed contbuild: 1. ASAN memory leak in Block::NewIterator (table/block.cc:429). the proper destruction of first_level_iter_ and second_level_iter_ of two_level_iterator.cc is missing from the code after the refactoring in #3406 2. various unused param errors introduced by #3662 3. updated comment for `ForceReleaseCachedEntry` to emphasize the use of `force_erase` flag. Closes #3718 Reviewed By: maysamyabandeh Differential Revision: D7621192 Pulled By: miasantreble fbshipit-source-id: 476c94264083a0730ded957c29de7807e4f5b146
this PR fixes a few failed contbuild:
ForceReleaseCachedEntry
to emphasize the use offorce_erase
flag.test plan: run asan, clang_release, lite, release, release_481 locally