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 NewRandomRWFile and ReuseWritableFile in KeyManagedEncryptedEnv #167

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Changes from all 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
10 changes: 8 additions & 2 deletions encryption/encryption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ Status KeyManagedEncryptedEnv::ReuseWritableFile(
const std::string& fname, const std::string& old_fname,
std::unique_ptr<WritableFile>* result, const EnvOptions& options) {
FileEncryptionInfo file_info;
Status s = key_manager_->GetFile(fname, &file_info);
// ReuseWritableFile is only used in the context of rotating WAL file and
// reuse them. Old content is discardable and new WAL records are to
// overwrite the file. So NewFile() should be called.
Status s = key_manager_->NewFile(fname, &file_info);
if (!s.ok()) {
return s;
}
Expand All @@ -379,7 +382,10 @@ Status KeyManagedEncryptedEnv::NewRandomRWFile(
const std::string& fname, std::unique_ptr<RandomRWFile>* result,
const EnvOptions& options) {
FileEncryptionInfo file_info;
Status s = key_manager_->NewFile(fname, &file_info);
// NewRandomRWFile is only used in the context of external file ingestion,
// for rewriting global seqno. So it should call GetFile() instead of
// NewFile().
Status s = key_manager_->GetFile(fname, &file_info);
if (!s.ok()) {
return s;
}
Expand Down