-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Begin forward compatibility for WAL entry #13225
Conversation
db/log_format.h
Outdated
}; | ||
constexpr int kMaxRecordType = kRecyclableUserDefinedTimestampSizeType; | ||
const int kRecordTypeSafeIgnoreMask = 1 << 5; | ||
constexpr int kMaxRecordType = kRecordTypeSafeIgnoreMask + 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will soon to be overwritten to be the last entry type in WAL that is greater than kRecordTypeSafeIgnoreMask in my upcoming PR.
@hx235 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
db/log_reader.cc
Outdated
ReportCorruption( | ||
(fragment.size() + (in_fragmented_record ? scratch->size() : 0)), | ||
reason.c_str()); | ||
if (record_type <= kRecordTypeSafeIgnoreMask) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a "mask", we should check it as a bit mask rather than a minimum value. Unless we have a sense of which is going to be most common, I suggest we split the remaining value space roughly in half for ignorable vs. rejected when unknown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Write("foo"); | ||
// Type is stored in header[6] | ||
IncrementByte(6, 100); | ||
FixChecksum(0, 3, false); | ||
ASSERT_EQ("EOF", Read()); | ||
ASSERT_EQ(3U, DroppedBytes()); | ||
ASSERT_EQ("OK", MatchError("unknown record type")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep be testing both the accepted and ignored unknown record type and rejected unknown record type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
dc07c04
to
bc3ae2c
Compare
@hx235 has updated the pull request. You must reimport the pull request before landing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks!
db/log_test.cc
Outdated
TEST_P(LogTest, IgnorableRecordType) { | ||
Write("foo"); | ||
// Type is stored in header[6] | ||
SetByte(6, static_cast<char>(kRecordTypeSafeIgnoreMask + 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use these in order, I recommend something like + 100
instead of + 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@hx235 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
bc3ae2c
to
02a86b9
Compare
@hx235 has updated the pull request. You must reimport the pull request before landing. |
@hx235 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Context/Summary:
This PR made WAL reader safely ignore type that is greater than some hard-coded value so old code can ignore new WAL
entry developed by new code.
Test:
Manually run crash test alternating on old (this PR) and new code (this PR + a new WAL entry kPredecessorWALInfo hx235@37e8b1a)
db_crashtest.py
New code
hx235@37e8b1a