[backupable db] Delete db_dir children when restoring backup

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
main
Igor Canadi 11 years ago
parent e9e6b00d29
commit 417b453fa6
  1. 13
      utilities/backupable/backupable_db.cc

@ -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()) {

Loading…
Cancel
Save