提交 94e139f9 编写于 作者: I Igor Canadi

Fixing failed delete file test

Summary: FindObsoleteFiles() has to be called before PurgeObsoleteFiles() because FindObsoleteFiles() sets manifest_file_number, log_number and prev_log_number to valid values.

Test Plan: deletefile_test now works

Reviewers: dhruba, emayanke, kailiu

Reviewed By: kailiu

CC: leveldb

Differential Revision: https://reviews.facebook.net/D13995
上级 65e45f0c
...@@ -1627,12 +1627,13 @@ void DBImpl::BackgroundCallFlush() { ...@@ -1627,12 +1627,13 @@ void DBImpl::BackgroundCallFlush() {
LogFlush(options_.info_log); LogFlush(options_.info_log);
env_->SleepForMicroseconds(1000000); env_->SleepForMicroseconds(1000000);
mutex_.Lock(); mutex_.Lock();
// clean up all the files we might have created // clean up all the files we might have created.
FindObsoleteFiles(deletion_state, true); FindObsoleteFiles(deletion_state, true);
} }
} }
// delete unnecessary files if any, this is done outside the mutex // delete unnecessary files if any, this is done outside the mutex
FindObsoleteFiles(deletion_state, false);
if (deletion_state.HaveSomethingToDelete()) { if (deletion_state.HaveSomethingToDelete()) {
mutex_.Unlock(); mutex_.Unlock();
PurgeObsoleteFiles(deletion_state); PurgeObsoleteFiles(deletion_state);
...@@ -1680,6 +1681,7 @@ void DBImpl::BackgroundCallCompaction() { ...@@ -1680,6 +1681,7 @@ void DBImpl::BackgroundCallCompaction() {
} }
// delete unnecessary files if any, this is done outside the mutex // delete unnecessary files if any, this is done outside the mutex
FindObsoleteFiles(deletion_state, false);
if (deletion_state.HaveSomethingToDelete()) { if (deletion_state.HaveSomethingToDelete()) {
mutex_.Unlock(); mutex_.Unlock();
PurgeObsoleteFiles(deletion_state); PurgeObsoleteFiles(deletion_state);
...@@ -1771,7 +1773,6 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, ...@@ -1771,7 +1773,6 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress,
versions_->ReleaseCompactionFiles(c.get(), status); versions_->ReleaseCompactionFiles(c.get(), status);
c->ReleaseInputs(); c->ReleaseInputs();
versions_->GetAndFreeObsoleteFiles(&deletion_state.sstdeletefiles); versions_->GetAndFreeObsoleteFiles(&deletion_state.sstdeletefiles);
FindObsoleteFiles(deletion_state, false);
*madeProgress = true; *madeProgress = true;
} }
c.reset(); c.reset();
...@@ -3363,6 +3364,7 @@ Status DBImpl::DeleteFile(std::string name) { ...@@ -3363,6 +3364,7 @@ Status DBImpl::DeleteFile(std::string name) {
if (status.ok()) { if (status.ok()) {
versions_->GetAndFreeObsoleteFiles(&deletion_state.sstdeletefiles); versions_->GetAndFreeObsoleteFiles(&deletion_state.sstdeletefiles);
} }
FindObsoleteFiles(deletion_state, false);
} // lock released here } // lock released here
LogFlush(options_.info_log); LogFlush(options_.info_log);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册