Skip to content
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

refactor(storage): replace PbHummockVersion with new HummockVersion struct #14101

Merged
merged 12 commits into from
Dec 26, 2023

Conversation

wenym1
Copy link
Contributor

@wenym1 wenym1 commented Dec 20, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

In this PR, we introduce a new separate struct for HummockVersion, HummockVersionDelta and HummockVersionCheckpoint. This is a refactor PR, and currently the fields in these structs are the same as the counterpart pb structs. This is for the meta data change introduced in #14041. The backward compatibility of meta data will be maintained in the from_protobuf method of these structs. In this PR we have limited all usages of their pb structs in rpc and metadata persistence. All other usages will be using the new struct.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

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.

@wenym1 wenym1 requested a review from a team as a code owner December 20, 2023 11:57
Copy link

codecov bot commented Dec 20, 2023

Codecov Report

Attention: 103 lines in your changes are missing coverage. Please review.

Comparison is base (7006fca) 68.06% compared to head (710d0eb) 67.97%.
Report is 40 commits behind head on main.

Files Patch % Lines
src/rpc_client/src/meta_client.rs 0.00% 23 Missing ⚠️
src/storage/hummock_sdk/src/table_watermark.rs 84.67% 19 Missing ⚠️
src/meta/service/src/hummock_service.rs 0.00% 17 Missing ⚠️
...ck_sdk/src/compaction_group/hummock_version_ext.rs 38.88% 11 Missing ⚠️
src/storage/hummock_sdk/src/version.rs 93.33% 8 Missing ⚠️
src/jni_core/src/hummock_iterator.rs 0.00% 4 Missing ⚠️
...eta/src/backup_restore/meta_snapshot_builder_v2.rs 0.00% 4 Missing ⚠️
src/meta/src/barrier/mod.rs 75.00% 4 Missing ⚠️
src/storage/backup/src/meta_snapshot_v2.rs 0.00% 3 Missing ⚠️
src/frontend/src/meta_client.rs 0.00% 2 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14101      +/-   ##
==========================================
- Coverage   68.06%   67.97%   -0.09%     
==========================================
  Files        1548     1549       +1     
  Lines      267474   267639     +165     
==========================================
- Hits       182052   181936     -116     
- Misses      85422    85703     +281     
Flag Coverage Δ
rust 67.97% <75.00%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@Little-Wallace Little-Wallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since PbHummockVersionDelta is only used to persist, is it necessary to replace it with a new struct ?

@wenym1
Copy link
Contributor Author

wenym1 commented Dec 21, 2023

Since PbHummockVersionDelta is only used to persist, is it necessary to replace it with a new struct ?

The initial motivation for this PR is for the meta data change introduced in #14041. In the issue we will change from using a single global max_committed_epoch to per-table max_committed_epoch. Since HummockVersion and HummockVersionDelta are persisted, this will be a breaking change and we need to maintain backward compatibility. So in this PR we implement a separate struct for these two metadata so that when we introduce the breaking change, we can maintain backward compatibility in the from_protobuf method and hide the difference between the two versions of metadata.

Copy link
Contributor

@zwang28 zwang28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest LGTM.

@@ -45,6 +45,7 @@ pub fn trigger_version_stat(
metrics
.max_committed_epoch
.set(current_version.max_committed_epoch as i64);
// TODO: this op may be costly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed we've seen version of tens of megabytes. Will any fix include in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed to implement an estimated_encoded_len by ourselves.

Copy link
Contributor

@Li0k Li0k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

}
}

pub fn estimated_encode_len(&self) -> usize {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the estimate of size need to correspond to all the member fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just an estimated encode len. For simplicity I only include the encode len of fields with variable length (e.g. list and map).

Copy link
Collaborator

@hzxa21 hzxa21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM!

src/storage/hummock_sdk/src/version.rs Outdated Show resolved Hide resolved
@wenym1 wenym1 added this pull request to the merge queue Dec 26, 2023
Merged via the queue into main with commit 94c4c91 Dec 26, 2023
27 of 28 checks passed
@wenym1 wenym1 deleted the yiming/hummock-version-struct branch December 26, 2023 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants