Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
hx235 committed Dec 15, 2024
1 parent fcb7e15 commit 4893ff9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
5 changes: 4 additions & 1 deletion db/log_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace ROCKSDB_NAMESPACE {
namespace log {

enum RecordType {
enum RecordType : int {
// Zero is reserved for preallocated files
kZeroType = 0,
kFullType = 1,
Expand All @@ -39,7 +39,10 @@ enum RecordType {
// User-defined timestamp sizes
kUserDefinedTimestampSizeType = 10,
kRecyclableUserDefinedTimestampSizeType = 11,

// Reserve kRecordTypeSafeIgnoreMask = 16
};
const int kRecordTypeSafeIgnoreMask = 1 << 4;
constexpr int kMaxRecordType = kRecyclableUserDefinedTimestampSizeType;

constexpr unsigned int kBlockSize = 32768;
Expand Down
24 changes: 14 additions & 10 deletions db/log_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,13 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
break;

default: {
std::string reason =
"unknown record type " + std::to_string(record_type);
ReportCorruption(
(fragment.size() + (in_fragmented_record ? scratch->size() : 0)),
reason.c_str());
if (record_type <= kRecordTypeSafeIgnoreMask) {
std::string reason =
"unknown record type " + std::to_string(record_type);
ReportCorruption(
(fragment.size() + (in_fragmented_record ? scratch->size() : 0)),
reason.c_str());
}
in_fragmented_record = false;
scratch->clear();
break;
Expand Down Expand Up @@ -781,11 +783,13 @@ bool FragmentBufferedReader::ReadRecord(Slice* record, std::string* scratch,
break;

default: {
std::string reason =
"unknown record type " + std::to_string(fragment_type_or_err);
ReportCorruption(
fragment.size() + (in_fragmented_record_ ? fragments_.size() : 0),
reason.c_str());
if (fragment_type_or_err <= kRecordTypeSafeIgnoreMask) {
std::string reason =
"unknown record type " + std::to_string(fragment_type_or_err);
ReportCorruption(
fragment.size() + (in_fragmented_record_ ? fragments_.size() : 0),
reason.c_str());
}
in_fragmented_record_ = false;
fragments_.clear();
break;
Expand Down

0 comments on commit 4893ff9

Please sign in to comment.