-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Track per-SST user-defined timestamp information in MANIFEST #9092
Conversation
@riversand963 I've reviewed this mr and my colleague post it. |
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.
Sorry again for the delay, have been a little busier lately.
Thanks @sunlike-Lipo for the PR, what this PR currently has LGTM.
I cannot find the logic of actually computing min/max timestamp for each file during flush/compaction/ingestion/..., is that going to me in another PR, or am I missing anything here?
cc @wolfkdy
db/version_edit.cc
Outdated
@@ -186,6 +186,13 @@ bool VersionEdit::EncodeTo(std::string* dst) const { | |||
PutVarint32(dst, NewFileCustomTag::kFileChecksumFuncName); | |||
PutLengthPrefixedSlice(dst, Slice(f.file_checksum_func_name)); | |||
|
|||
if (f.max_timestamp != kDisableUserTimestamp) { | |||
assert(f.min_timestamp != kDisableUserTimestamp); |
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.
Can we return false
if assertion fails?
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.
sure, fixed
f.min_timestamp = field.ToString(); | ||
break; | ||
case kMaxTimestamp: | ||
f.max_timestamp = field.ToString(); |
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.
Can we add a check for the equality of min_timestamp.size()
and max_timestamp.size()
somewhere in this method?
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.
sure, added
oh, you split that to #9093 . |
I also suggest that the description of this PR be updated since it's too short now. It would be great if the description can briefly mention we introduce (compatible) format changes to MANIFEST, etc. |
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.
Left a few more comments.
db/version_edit.cc
Outdated
@@ -186,6 +186,15 @@ bool VersionEdit::EncodeTo(std::string* dst) const { | |||
PutVarint32(dst, NewFileCustomTag::kFileChecksumFuncName); | |||
PutLengthPrefixedSlice(dst, Slice(f.file_checksum_func_name)); | |||
|
|||
if (f.max_timestamp != kDisableUserTimestamp) { | |||
if (f.min_timestamp == kDisableUserTimestamp) { |
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.
I prefer a more strict check.
if (f.min_timestamp.size() != f.max_timestamp.size()) {
assert(false);
return false;
}
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.
ok, I fixed it as your suggestion.
db/version_edit.cc
Outdated
@@ -315,6 +324,7 @@ const char* VersionEdit::DecodeNewFile4From(Slice* input) { | |||
return "new-file4 custom field"; | |||
} | |||
if (custom_tag == kTerminate) { | |||
assert(f.min_timestamp.size() == f.max_timestamp.size()); |
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.
In case of error, we need to return a string literal to indicate error. THe assertion will be optimized away in opt build mode.
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.
ok, I added some return msg after assert.
…8957 Rockdb has supported user-defined timestamp feature. Application can specify a timestamp when writing each k-v pair. When data flush from memory to disk file called SST files, file creation activity will commit to MANIFEST. This commit is for tracking timestamp info in the MANIFEST for each file. The changes involved are as follows: 1) Track max/min timestamp in FileMetaData, and fix invoved codes. 2) Add max/min timestamp in NewFileCustomTag(in the knEWfILE4 part), and support invoved codes such as VersionEdit Encode and Decode etc. 3) Add unit test code for VersionEdit EncodeDecodeNewFile4, and fix invoved test codes.
I add some description about this pr. Thanks a lot for suggestion. |
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.
Thanks @sunlike-Lipo for the PR. Mostly LGTM except two minor comments.
db/version_edit.cc
Outdated
r.append(" min_timestamp:"); | ||
r.append(f.min_timestamp); | ||
r.append(" max_timestamp:"); | ||
r.append(f.max_timestamp); |
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.
Sorry for this late comment.
I think printing the timestamps in hex format seems better.
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.
OK. now fix it to Slice(f.min_timestamp).ToString(true).
db/version_edit.cc
Outdated
jw << "MinTimestamp" << f.min_timestamp; | ||
jw << "MaxTimestamp" << f.max_timestamp; |
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.
Print timestamp in hex format?
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.
OK. now fix it to Slice(f.min_timestamp).ToString(true).
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@sunlike-Lipo has updated the pull request. You must reimport the pull request before landing. |
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Turns out our internal linter is unhappy about putting kDisableUserTimestamp definition in dbformat.h. Can we declare it in dbformat.h and define it in dbformat.cc? |
@sunlike-Lipo has updated the pull request. You must reimport the pull request before landing. |
Sure. That sounds more reasonable. fixed |
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Thanks @sunlike-Lipo a lot for the PR! I have already initiated internal review process for merging. |
@sunlike-Lipo has updated the pull request. You must reimport the pull request before landing. |
@sunlike-Lipo has updated the pull request. You must reimport the pull request before landing. |
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
OK, I modified the HISTORY.md. |
@riversand963 merged this pull request in 937fbcb. |
Track per-SST user-defined timestamp information in MANIFEST #8957
Rockdb has supported user-defined timestamp feature. Application can specify a timestamp
when writing each k-v pair. When data flush from memory to disk file called SST files, file
creation activity will commit to MANIFEST. This commit is for tracking timestamp info in the
MANIFEST for each file. The changes involved are as follows:
Summary:
NewFileCustomTag ( in the kNewFile4 part ), and support invoved codes such as
VersionEdit Encode and Decode etc.