-
Notifications
You must be signed in to change notification settings - Fork 587
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
feat(storage): support hummock time travel #17621
Conversation
@chenzl25 Would you please help to review the lookupjoin part, as well as the |
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.
license-eye has totally checked 5195 files.
Valid | Invalid | Ignored | Fixed |
---|---|---|---|
2219 | 1 | 2975 | 0 |
Click to see the invalid file list
- src/meta/src/hummock/manager/time_travel.rs
Sure! |
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 need to consider index selection during time travel. There are 2 places we need to pass the time travel information to the index.
pub fn to_index_scan_if_index_covered(&self, index: &Rc<IndexCatalog>) -> Option<LogicalScan> { - https://github.com/risingwavelabs/risingwave/blob/bd9dcfc064df4642e9c0d674b3bd64f7aeb4d3f7/src/frontend/src/optimizer/rule/index_selection_rule.rs
|
Other changes includes in another coming PR:
|
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 some early comments first. Will continue afterwards.
.on_conflict( | ||
OnConflict::column(hummock_sstable_info::Column::SstId) | ||
.do_nothing() | ||
.to_owned(), | ||
) | ||
.do_nothing() | ||
.exec(txn) |
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.
Will this introduce excessive load on meta store given that there can be many SSTs in a version even though many of them already exist in the hummock_sstable_info
table? I am thinking whether we should maintain an in-memory set for sst ids in hummock_sstable_info
to avoid unneccesary traffic to meta store. Same trick applies to other time travel related meta store tables.
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.
an in-memory set for sst ids in hummock_sstable_info
+1 because it's in the critical path commit_epoch
other time travel related meta store tables
It seems unnecessary to me because there won't be many conflict insert for them. Besides, for the read path the complete metadata is required rather than the index (*_id), which would be very large in memory.
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.
See last_time_travel_snapshot_sst_ids
. It is much simpler than maintaining a full set of sst ids, at the cost of less accuracy, i.e. sometimes there'll still be attempts to unnecessarily write the same SSTs into meta store. But it's good enough and avoid introducing locking in truncate_time_travel_metadata
.
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.
Rest LGTM because most logics are non-intrusive to the existing logics,
/// Clone from an `SstableInfo`, but only set the `sst_id` for the target, leaving other fields as default. | ||
/// The goal is to reduce the size of pb object generated afterward. | ||
fn stripped_sstable_info(origin: &SstableInfo) -> SstableInfo { | ||
SstableInfo { |
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.
This is a note instead of a comment. At the first glance, I think we can just have a new struct with sstable_info to be an Option
instead of still writing 12 empty fields, which may occupy the space unneccessarily. I then realized that this is because to do so we need a new struct for each nested pb messages in HummockVersion including Levels
, Level
, OverlappngLevel
and ... Eventually I think we should get rid of using PBs directly in meta and switch to our own struct (probably with Arc on sstable info as well to save memory) but yeah we don't need to do that in this PR.
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
(cherry picked from commit 5230e97)
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
This PR's LOC is substantial but the concept is straightforward. Tips for reviewers: the major changes comes in the 2 new files:
src/storage/hummock_sdk/src/time_travel.rs
. It converts betweenHummockVersion
with and without the sizableSstableInfo
, as well asHummockVersionDelta
.src/meta/src/hummock/manager/time_travel.rs
. It reads and writes metadata for time travel.This PR support point-in-time time travel query for table/MVs.
The basic idea is:
SstableInfo
has been replaced with thinSstableId
.SstableInfo
has been replaced with thinSstableId
, i.e. ref toSstableInfo
.SstableInfo
used by delta and version from step 2 and 3. It's used to recover delta and version from step 2 and 3 afterward.SELECT ... FROM ... FOR SYSTEM_TIME AS OF unix_timestamp
.HummockStorage
in compute node converts this system time to an epoch and fetch an eligible time travel Hummock version from meta node. This RPC to the meta node can potentially be optimized out in the future.HummockStorage
get/iter over this time travel Hummock version.Not in this PR:
AS OF unix_timestamp
syntax. Will add test after supportAS OF now - interval
in other PR.Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.