Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix renaming encrypted directory and check compaction paused during checkpoint #338

Merged
merged 7 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions encryption/encryption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -527,23 +527,22 @@ Status KeyManagedEncryptedEnv::RenameFile(const std::string& src_fname,
}
s = target()->RenameFile(src_fname, dst_fname);
if (s.ok()) {
s = key_manager_->DeleteFile(src_fname);
s = key_manager_->DeleteFileExt(src_fname, dst_fname);
} else {
Status delete_status __attribute__((__unused__)) =
key_manager_->DeleteFile(dst_fname);
key_manager_->DeleteFileExt(dst_fname, src_fname);
assert(delete_status.ok());
}
return s;
}

Status KeyManagedEncryptedEnv::DeleteDir(const std::string& dname) {
Status s = target()->DeleteDir(dname);
// We don't guarantee atomicity. Delete keys first.
Status s = key_manager_->DeleteFile(dname);
overvenus marked this conversation as resolved.
Show resolved Hide resolved
if (!s.ok()) {
return s;
}
// We don't use a dedicated `DeleteDir` function, because RocksDB already uses
// `RenameFile` for both file and directory.
return key_manager_->DeleteFile(dname);
return target()->DeleteDir(dname);
}

Env* NewKeyManagedEncryptedEnv(Env* base_env,
Expand Down
6 changes: 6 additions & 0 deletions include/rocksdb/encryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class KeyManager {
virtual Status DeleteFile(const std::string& fname) = 0;
virtual Status LinkFile(const std::string& src_fname,
const std::string& dst_fname) = 0;
// Provide additional hint of physical file when the key name doesn't map to
// one.
virtual Status DeleteFileExt(const std::string& fname,
const std::string& /*physical_fname*/) {
overvenus marked this conversation as resolved.
Show resolved Hide resolved
return DeleteFile(fname);
}
};

// An Env with underlying files being encrypted. It holds a reference to an
Expand Down