From 2d618bcaffaf3648b2dc363321dd8b56b9fd3e2a Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Fri, 10 May 2024 16:55:20 -0700 Subject: [PATCH] Fix recycled WAL detection with kSetCompressionType record --- db/log_reader.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/log_reader.cc b/db/log_reader.cc index 110eb2c27c8b..525129fe25ae 100644 --- a/db/log_reader.cc +++ b/db/log_reader.cc @@ -487,9 +487,11 @@ unsigned int Reader::ReadPhysicalRecord(Slice* result, size_t* drop_size, type == kRecyclableUserDefinedTimestampSizeType); if (is_recyclable_type) { header_size = kRecyclableHeaderSize; - if (end_of_buffer_offset_ - buffer_.size() == 0) { - recycled_ = true; + if (!first_record_read_ && !recycled_) { + // A recycled log should have started with a recycled record + return kBadRecord; } + recycled_ = true; // We need enough for the larger header if (buffer_.size() < static_cast(kRecyclableHeaderSize)) { int r = kEof;