From 95c192475df4ad2c1e542b3c08d0e978df96deca Mon Sep 17 00:00:00 2001 From: Wanning Jiang Date: Wed, 29 Jun 2016 15:33:27 -0700 Subject: [PATCH] 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 --- util/env_basic_test.cc | 5 +++++ utilities/backupable/backupable_db.cc | 3 +++ 2 files changed, 8 insertions(+) diff --git a/util/env_basic_test.cc b/util/env_basic_test.cc index 471886460..69939ce8b 100644 --- a/util/env_basic_test.cc +++ b/util/env_basic_test.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 seq_file; @@ -286,6 +290,7 @@ TEST_P(EnvMoreTestWithParam, GetChildren) { unique_ptr 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()); diff --git a/utilities/backupable/backupable_db.cc b/utilities/backupable/backupable_db.cc index 1f18e119e..33c6874d4 100644 --- a/utilities/backupable/backupable_db.cc +++ b/utilities/backupable/backupable_db.cc @@ -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; }