From 7169ca9c8010a69da1d35c733425b1d379c16732 Mon Sep 17 00:00:00 2001 From: Cheng Chang Date: Wed, 18 Nov 2020 21:24:32 -0800 Subject: [PATCH] Do not track empty WALs (#7697) Summary: An empty WAL won't be backed up by the BackupEngine. So if we track the empty WALs in MANIFEST, then when restoring from a backup, it may report corruption that the empty WAL is missing, which is correct because the WAL is actually in the main DB but not in the backup DB, but missing an empty WAL does not logically break DB consistency. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7697 Test Plan: watch existing tests to pass Reviewed By: pdillinger Differential Revision: D25077194 Pulled By: cheng-chang fbshipit-source-id: 01917b57234b92b6063925f2ee9452c5732bdc03 --- db/db_impl/db_impl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index 5a1fde9aa..d158ebcfd 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -1323,7 +1323,8 @@ Status DBImpl::MarkLogsSynced(uint64_t up_to, bool synced_dir) { auto& wal = *it; assert(wal.getting_synced); if (logs_.size() > 1) { - if (immutable_db_options_.track_and_verify_wals_in_manifest) { + if (immutable_db_options_.track_and_verify_wals_in_manifest && + wal.writer->file()->GetFileSize() > 0) { synced_wals.AddWal(wal.number, WalMetadata(wal.writer->file()->GetFileSize())); }