Skip to content

Commit

Permalink
Keep compatiblity to Open old Pegasus version DB (facebook#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 authored Jul 2, 2020
1 parent 551a110 commit af8729e
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion db/version_edit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ enum Tag : uint32_t {
kNewFile = 7,
// 8 was used for large value refs
kPrevLogNumber = 9,
kMinLogNumberToKeep = 10,
kLastFlushSeqDecree = 10,
// On official branch, kMinLogNumberToKeep = 10, but on Pegasus branch we
// have introduced a new flag kLastFlushSeqDecree = 10 in previous version,
// so intend to keep compatible with old Pegasus version, we have to set
// kMinLogNumberToKeep = 11.
kMinLogNumberToKeep = 11,
// Ignore-able field
kDbId = kTagSafeIgnoreMask + 1,

Expand All @@ -48,6 +53,8 @@ enum Tag : uint32_t {
kColumnFamilyAdd = 201,
kColumnFamilyDrop = 202,
kMaxColumnFamily = 203,
kPegasusDataVersion = 204,
kLastManualCompactFinishTime = 205,

kInAtomicGroup = 300,
};
Expand Down Expand Up @@ -447,6 +454,16 @@ Status VersionEdit::DecodeFrom(const Slice& src) {
}
break;

case kLastFlushSeqDecree:
uint64_t last_flush_sequence;
uint64_t last_flush_decree;
if (GetVarint64(&input, &last_flush_sequence) && GetVarint64(&input, &last_flush_decree)) {
// Just read these fileds to keep compatible with old version
} else {
msg = "last flush sequence number and decree";
}
break;

case kMaxColumnFamily:
if (GetVarint32(&input, &max_column_family_)) {
has_max_column_family_ = true;
Expand All @@ -463,6 +480,24 @@ Status VersionEdit::DecodeFrom(const Slice& src) {
}
break;

case kPegasusDataVersion:
uint32_t pegasus_data_version;
if (GetVarint32(&input, &pegasus_data_version)) {
// Just read these fileds to keep compatible with old version
} else {
msg = "Pegasus data version";
}
break;

case kLastManualCompactFinishTime:
uint64_t last_manual_compact_finish_time;
if (GetVarint64(&input, &last_manual_compact_finish_time)) {
// Just read these fileds to keep compatible with old version
} else {
msg = "last manual compact finish time";
}
break;

case kCompactPointer:
if (GetLevel(&input, &level, &msg) &&
GetInternalKey(&input, &key)) {
Expand Down

0 comments on commit af8729e

Please sign in to comment.