diff --git a/db/column_family_test.cc b/db/column_family_test.cc index 9db46c61d9e2a8b08fdb991076633993cf2e5e2e..aaf511b6ebe82c4fa80421eb3e771f3150b09124 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -941,6 +941,12 @@ TEST_F(ColumnFamilyTest, CrashAfterFlush) { db_options_.env = env_; } +TEST_F(ColumnFamilyTest, OpenNonexistentColumnFamily) { + ASSERT_OK(TryOpen({"default"})); + Close(); + ASSERT_TRUE(TryOpen({"default", "dne"}).IsInvalidArgument()); +} + #ifndef ROCKSDB_LITE // WaitForFlush() is not supported // Makes sure that obsolete log files get deleted TEST_F(ColumnFamilyTest, DifferentWriteBufferSizes) { diff --git a/db/db_impl.cc b/db/db_impl.cc index f202d1fa6dafdca6236e3eb99eb03e41bd198cfa..b2941848a951515ddb44a10c3f3e58f52f169d57 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1688,6 +1688,9 @@ Status DBImpl::RecoverLogFiles(const std::vector& log_numbers, } } + // True if there's any data in the WALs; if not, we can skip re-processing + // them later + bool data_seen = false; if (!read_only) { // no need to refcount since client still doesn't have access // to the DB and can not drop column families while we iterate @@ -1723,6 +1726,7 @@ Status DBImpl::RecoverLogFiles(const std::vector& log_numbers, cfd->CreateNewMemtable(*cfd->GetLatestMutableCFOptions(), versions_->LastSequence()); } + data_seen = true; } // write MANIFEST with update @@ -1748,7 +1752,7 @@ Status DBImpl::RecoverLogFiles(const std::vector& log_numbers, } } - if (!flushed) { + if (data_seen && !flushed) { // Mark these as alive so they'll be considered for deletion later by // FindObsoleteFiles() for (auto log_number : log_numbers) {