Skip to content

Commit

Permalink
[backupable db] Delete db_dir children when restoring backup
Browse files Browse the repository at this point in the history
Summary:
I realized that manifest will get deleted by PurgeObsoleteFiles in DBImpl, but it is sill cleaner to delete
files before we restore the backup

Test Plan: backupable_db_test

Reviewers: dhruba

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D14619
  • Loading branch information
igorcanadi committed Dec 12, 2013
1 parent e9e6b00 commit 417b453
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions utilities/backupable/backupable_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,18 @@ Status BackupEngine::RestoreDBFromBackup(BackupID backup_id,
// delete log files that might have been already in wal_dir.
// This is important since they might get replayed to the restored DB,
// which will then differ from the backuped DB
std::vector<std::string> wal_dir_children;
db_env_->GetChildren(wal_dir, &wal_dir_children); // ignore errors
for (auto f : wal_dir_children) {
std::vector<std::string> delete_children;
db_env_->GetChildren(wal_dir, &delete_children); // ignore errors
for (auto f : delete_children) {
db_env_->DeleteFile(wal_dir + "/" + f); // ignore errors
}
// Also delete all the db_dir children. This is not so important
// because obsolete files will be deleted by DBImpl::PurgeObsoleteFiles()
delete_children.clear();
db_env_->GetChildren(db_dir, &delete_children); // ignore errors
for (auto f : delete_children) {
db_env_->DeleteFile(db_dir + "/" + f); // ignore errors
}

Status s;
for (auto& file : backup.GetFiles()) {
Expand Down

0 comments on commit 417b453

Please sign in to comment.