Combine two FindObsoleteFiles()
Summary: We don't need to call FindObsoleteFiles() twice Test Plan: deletefile_test Reviewers: dhruba Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D14007
This commit is contained in:
parent
0ef628537c
commit
4abd219cfc
@ -1613,8 +1613,9 @@ void DBImpl::BackgroundCallFlush() {
|
|||||||
assert(bg_flush_scheduled_);
|
assert(bg_flush_scheduled_);
|
||||||
MutexLock l(&mutex_);
|
MutexLock l(&mutex_);
|
||||||
|
|
||||||
|
Status s;
|
||||||
if (!shutting_down_.Acquire_Load()) {
|
if (!shutting_down_.Acquire_Load()) {
|
||||||
Status s = BackgroundFlush(&madeProgress, deletion_state);
|
s = BackgroundFlush(&madeProgress, deletion_state);
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
// Wait a little bit before retrying background compaction in
|
// Wait a little bit before retrying background compaction in
|
||||||
// case this is an environmental problem and we do not want to
|
// case this is an environmental problem and we do not want to
|
||||||
@ -1627,13 +1628,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.
|
|
||||||
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 !s.ok(), this means that Flush failed. In that case, we want
|
||||||
|
// to delete all obsolete files and we force FindObsoleteFiles()
|
||||||
|
FindObsoleteFiles(deletion_state, !s.ok());
|
||||||
if (deletion_state.HaveSomethingToDelete()) {
|
if (deletion_state.HaveSomethingToDelete()) {
|
||||||
mutex_.Unlock();
|
mutex_.Unlock();
|
||||||
PurgeObsoleteFiles(deletion_state);
|
PurgeObsoleteFiles(deletion_state);
|
||||||
@ -1661,8 +1662,9 @@ void DBImpl::BackgroundCallCompaction() {
|
|||||||
MutexLock l(&mutex_);
|
MutexLock l(&mutex_);
|
||||||
// Log(options_.info_log, "XXX BG Thread %llx process new work item", pthread_self());
|
// Log(options_.info_log, "XXX BG Thread %llx process new work item", pthread_self());
|
||||||
assert(bg_compaction_scheduled_);
|
assert(bg_compaction_scheduled_);
|
||||||
|
Status s;
|
||||||
if (!shutting_down_.Acquire_Load()) {
|
if (!shutting_down_.Acquire_Load()) {
|
||||||
Status s = BackgroundCompaction(&madeProgress, deletion_state);
|
s = BackgroundCompaction(&madeProgress, deletion_state);
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
// Wait a little bit before retrying background compaction in
|
// Wait a little bit before retrying background compaction in
|
||||||
// case this is an environmental problem and we do not want to
|
// case this is an environmental problem and we do not want to
|
||||||
@ -1675,13 +1677,15 @@ void DBImpl::BackgroundCallCompaction() {
|
|||||||
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
|
|
||||||
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 !s.ok(), this means that Compaction failed. In that case, we want
|
||||||
|
// to delete all obsolete files we might have created and we force
|
||||||
|
// FindObsoleteFiles(). This is because deletion_state does not catch
|
||||||
|
// all created files if compaction failed.
|
||||||
|
FindObsoleteFiles(deletion_state, !s.ok());
|
||||||
if (deletion_state.HaveSomethingToDelete()) {
|
if (deletion_state.HaveSomethingToDelete()) {
|
||||||
mutex_.Unlock();
|
mutex_.Unlock();
|
||||||
PurgeObsoleteFiles(deletion_state);
|
PurgeObsoleteFiles(deletion_state);
|
||||||
|
Loading…
Reference in New Issue
Block a user