writable file close before reset

Summary: during backup, writable file should call close() before reset()

Test Plan: backupable_db_test.cc

Reviewers: andrewkr

Reviewed By: andrewkr

Subscribers: andrewkr, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D60195
main
Wanning Jiang 9 years ago
parent 197b832afa
commit 95c192475d
  1. 5
      util/env_basic_test.cc
  2. 3
      utilities/backupable/backupable_db.cc

@ -94,6 +94,7 @@ TEST_P(EnvBasicTestWithParam, Basics) {
// Create a file.
ASSERT_OK(env_->NewWritableFile(test_dir_ + "/f", &writable_file, soptions_));
ASSERT_OK(writable_file->Close());
writable_file.reset();
// Check that the file exists.
@ -107,6 +108,7 @@ TEST_P(EnvBasicTestWithParam, Basics) {
// Write to the file.
ASSERT_OK(env_->NewWritableFile(test_dir_ + "/f", &writable_file, soptions_));
ASSERT_OK(writable_file->Append("abc"));
ASSERT_OK(writable_file->Close());
writable_file.reset();
// Check for expected size.
@ -152,6 +154,7 @@ TEST_P(EnvBasicTestWithParam, ReadWrite) {
ASSERT_OK(env_->NewWritableFile(test_dir_ + "/f", &writable_file, soptions_));
ASSERT_OK(writable_file->Append("hello "));
ASSERT_OK(writable_file->Append("world"));
ASSERT_OK(writable_file->Close());
writable_file.reset();
// Read sequentially.
@ -213,6 +216,7 @@ TEST_P(EnvBasicTestWithParam, LargeWrite) {
ASSERT_OK(env_->NewWritableFile(test_dir_ + "/f", &writable_file, soptions_));
ASSERT_OK(writable_file->Append("foo"));
ASSERT_OK(writable_file->Append(write_data));
ASSERT_OK(writable_file->Close());
writable_file.reset();
unique_ptr<SequentialFile> seq_file;
@ -286,6 +290,7 @@ TEST_P(EnvMoreTestWithParam, GetChildren) {
unique_ptr<WritableFile> writable_file;
ASSERT_OK(
env_->NewWritableFile(test_dir_ + "/file", &writable_file, soptions_));
ASSERT_OK(writable_file->Close());
writable_file.reset();
ASSERT_TRUE(!env_->GetChildren(test_dir_ + "/file", &children).ok());
ASSERT_EQ(0U, children.size());

@ -1278,6 +1278,9 @@ Status BackupEngineImpl::CopyOrCreateFile(
if (s.ok() && sync) {
s = dest_writer->Sync(false);
}
if (s.ok()) {
s = dest_writer->Close();
}
return s;
}

Loading…
Cancel
Save