diff --git a/db/db_impl.cc b/db/db_impl.cc index 167941375..b2cfe4d33 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -2178,8 +2178,13 @@ Status DBImpl::MakeRoomForWrite(bool force) { assert(versions_->PrevLogNumber() == 0); uint64_t new_log_number = versions_->NewFileNumber(); unique_ptr lfile; - s = env_->NewWritableFile(LogFileName(dbname_, new_log_number), &lfile, - storage_options_); + StorageOptions soptions(storage_options_); + soptions.DisableMmapWrites(); + s = env_->NewWritableFile( + LogFileName(dbname_, new_log_number), + &lfile, + soptions + ); if (!s.ok()) { // Avoid chewing through file number space in a tight loop. versions_->ReuseFileNumber(new_log_number); @@ -2394,6 +2399,7 @@ Status DB::Open(const Options& options, const std::string& dbname, if (s.ok()) { uint64_t new_log_number = impl->versions_->NewFileNumber(); unique_ptr lfile; + soptions.DisableMmapWrites(); s = options.env->NewWritableFile(LogFileName(dbname, new_log_number), &lfile, soptions); if (s.ok()) { diff --git a/db/db_test.cc b/db/db_test.cc index 38f960575..143a1fc5c 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2664,24 +2664,23 @@ TEST(DBTest, TransactionLogIteratorMoveOverZeroFiles) { auto iter = OpenTransactionLogIter(0); ExpectRecords(2, iter); } -// Disabled currently as does not work with mmaped files. -// -// TEST(DBTest, TransactionLogIteratorStallAtLastRecord) { -// Options options = OptionsForLogIterTest(); -// DestroyAndReopen(&options); -// Put("key1", DummyString(1024)); -// auto iter = OpenTransactionLogIter(0); -// ASSERT_OK(iter->status()); -// ASSERT_TRUE(iter->Valid()); -// iter->Next(); -// ASSERT_TRUE(!iter->Valid()); -// ASSERT_OK(iter->status()); -// Put("key2", DummyString(1024)); -// iter->Next(); -// ASSERT_OK(iter->status()); -// ASSERT_TRUE(iter->Valid()); -// } -// + +TEST(DBTest, TransactionLogIteratorStallAtLastRecord) { + Options options = OptionsForLogIterTest(); + DestroyAndReopen(&options); + Put("key1", DummyString(1024)); + auto iter = OpenTransactionLogIter(0); + ASSERT_OK(iter->status()); + ASSERT_TRUE(iter->Valid()); + iter->Next(); + ASSERT_TRUE(!iter->Valid()); + ASSERT_OK(iter->status()); + Put("key2", DummyString(1024)); + iter->Next(); + ASSERT_OK(iter->status()); + ASSERT_TRUE(iter->Valid()); +} + TEST(DBTest, ReadCompaction) { std::string value(4096, '4'); // a string of size 4K { diff --git a/util/storage_options.h b/util/storage_options.h index 9f3ec8b03..54dfb23dc 100644 --- a/util/storage_options.h +++ b/util/storage_options.h @@ -50,6 +50,10 @@ class StorageOptions : public EnvOptions { bool UseMmapWrites() const { return use_mmap_writes_; } bool UseReadaheadCompactions() const { return readahead_compactions_;} + void DisableMmapWrites() { + use_mmap_writes_ = false; + } + private: bool data_in_os_; bool fs_readahead_;