Skip to content

Commit

Permalink
db/repair: reset Repair::db_lock_ in ctor (facebook#4683)
Browse files Browse the repository at this point in the history
Summary:
there is chance that

* the caller tries to repair the db when holding the db_lock, in
  that case the env implementation might not set the `lock`
  parameter of Repairer::Run().
* the caller somehow never calls Repairer::Run().

either way, the desctructor of Repair will compare the uninitialized
db_lock_ with nullptr, and tries to unlock it. there is good chance
that the db_lock_ is not nullptr, then boom.

Signed-off-by: Kefu Chai <[email protected]>
Pull Request resolved: facebook#4683

Differential Revision: D13260287

Pulled By: riversand963

fbshipit-source-id: 878a119d2e9f10a0fa17ee62cf3fb24b33d49fa5
  • Loading branch information
tchaikov authored and facebook-github-bot committed Nov 29, 2018
1 parent 8d9b4d9 commit 7dbee38
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion db/repair.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class Repairer {
wc_(db_options_.delayed_write_rate),
vset_(dbname_, &immutable_db_options_, env_options_,
raw_table_cache_.get(), &wb_, &wc_),
next_file_number_(1) {
next_file_number_(1),
db_lock_(nullptr) {
for (const auto& cfd : column_families) {
cf_name_to_opts_[cfd.name] = cfd.options;
}
Expand Down

0 comments on commit 7dbee38

Please sign in to comment.