From ea2d729075170f50b3f2f5192faf6dd9abb60c3c Mon Sep 17 00:00:00 2001 From: Bilal Akhtar Date: Wed, 18 Mar 2020 15:07:20 -0400 Subject: [PATCH] db_impl_open: Error out if WAL replay seqnums aren't increasing This should help trip early on issues such as the one found in: https://github.com/cockroachdb/pebble/issues/567 --- db/db_impl_open.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/db/db_impl_open.cc b/db/db_impl_open.cc index 28de2ad1a67..4f760e73760 100644 --- a/db/db_impl_open.cc +++ b/db/db_impl_open.cc @@ -763,6 +763,13 @@ Status DBImpl::RecoverLogFiles(const std::vector& log_numbers, // we just ignore the update. // That's why we set ignore missing column families to true bool has_valid_writes = false; + if (*next_sequence != kMaxSequenceNumber && sequence < *next_sequence) { + status = Status::Corruption( + "Sequence numbers in WAL not in increasing order: " + + NumberToString(sequence) + " < " + NumberToString(*next_sequence)); + reporter.Corruption(record.size(), status); + continue; + } status = WriteBatchInternal::InsertInto( &batch, column_family_memtables_.get(), &flush_scheduler_, true, log_number, this, false /* concurrent_memtable_writes */,