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
This commit is contained in:
Cheng Chang 2020-11-18 21:24:32 -08:00 committed by Facebook GitHub Bot
parent 8a97f35619
commit 7169ca9c80

View File

@ -1323,7 +1323,8 @@ Status DBImpl::MarkLogsSynced(uint64_t up_to, bool synced_dir) {
auto& wal = *it; auto& wal = *it;
assert(wal.getting_synced); assert(wal.getting_synced);
if (logs_.size() > 1) { 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, synced_wals.AddWal(wal.number,
WalMetadata(wal.writer->file()->GetFileSize())); WalMetadata(wal.writer->file()->GetFileSize()));
} }