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(compaction): deprecate safe_epoch #18491

Merged
merged 18 commits into from
Sep 20, 2024

Conversation

zwang28
Copy link
Contributor

@zwang28 zwang28 commented Sep 11, 2024

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

What's changed and what's your intention?

After this PR,

  • All usage of HummockVersion::safe_epoch, HummockVersionDelta::safe_epoch, StateTableInfo::safe_epoch, StateTableInfoDelta::safe_epoch have been removed.
  • During compaction, only retain the latest version for each key. i.e. it ignores safe_epoch.
  • For each vnode, only retain the latest table watermark in HummockVersion.

Should merge after #18477

#18214

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.

@zwang28 zwang28 force-pushed the wangzheng/compaction_ignore_safe_epoch branch from e268a92 to 0e7591f Compare September 11, 2024 08:09
@zwang28 zwang28 force-pushed the wangzheng/compaction_ignore_safe_epoch branch from 0e7591f to 62b477f Compare September 11, 2024 08:34
@zwang28 zwang28 changed the title refactor(compaction): deprecate safe_epoch in compaction refactor(compaction): deprecate safe_epoch Sep 11, 2024
@zwang28 zwang28 force-pushed the wangzheng/compaction_ignore_safe_epoch branch from 62b477f to 95d0172 Compare September 12, 2024 02:47
@zwang28 zwang28 requested a review from wenym1 September 12, 2024 06:51
Copy link
Contributor

@wenym1 wenym1 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. @Li0k please review the compaction part.

@@ -54,7 +54,6 @@ pub struct MetaSnapshotMetadata {
pub hummock_version_id: HummockVersionId,
pub ssts: HashSet<HummockSstableObjectId>,
pub max_committed_epoch: u64,
pub safe_epoch: u64,
Copy link
Contributor

Choose a reason for hiding this comment

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

Will removing this field affect the backward compatibility to the previously created snapshot?

Copy link
Contributor Author

@zwang28 zwang28 Sep 12, 2024

Choose a reason for hiding this comment

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

Ideally for backward compatibiliy, the deserializer should be able to ignore the unknown field safe_epoch. However it doesn't work out of box and requires to further customize MetaSnapshotMetadata's serde. To be specific, the MetaSnapshotMetadata::safe_epoch is ignored automatically, however I don't find a convenient way to make it also ignore the safe_epoch in MetaSnapshotMetadata::state_table_info.

This PR "fixed" the compatibility issue by ignornig the whole state table info from previous meta snapshot. The state table info is used only for query backup, which is rarely used. So I think it's fine.

src/storage/backup/integration_tests/run_all.sh Outdated Show resolved Hide resolved
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone)]
pub struct StateTableInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to reimplement a new struct instead of using the pb?

Copy link
Contributor Author

@zwang28 zwang28 Sep 12, 2024

Choose a reason for hiding this comment

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

It allows more control over how StateTableInfo is serialized. For example, previously a u64 field in PbStateTableInfo will be serialized as String by serde_json, which is not consistent with other fields of MetaSnapshotMetadata. I want to prevent this inconsistency.

src/storage/hummock_sdk/src/table_watermark.rs Outdated Show resolved Hide resolved
@zwang28 zwang28 force-pushed the wangzheng/compaction_ignore_safe_epoch branch from bbc1491 to 0d50ccf Compare September 12, 2024 14:09
Copy link
Contributor

@wenym1 wenym1 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 Show resolved Hide resolved
} else {
None
}
Some(TableWatermarks {
Copy link
Contributor

Choose a reason for hiding this comment

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

In a previous commit 9631102, the changes was reverted. Any reason to change it again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explained here #18491 (comment)
Unlike the previous safe_epoch, relying on earliest_epoch = committed_epoch is too strict and may never be satisfied in my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. The changes LGTM.

src/storage/hummock_test/src/hummock_storage_tests.rs Outdated Show resolved Hide resolved
@zwang28 zwang28 enabled auto-merge September 20, 2024 05:41
@zwang28 zwang28 added this pull request to the merge queue Sep 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 20, 2024
@zwang28 zwang28 enabled auto-merge September 20, 2024 06:32
@zwang28 zwang28 added this pull request to the merge queue Sep 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 20, 2024
@zwang28 zwang28 added this pull request to the merge queue Sep 20, 2024
Merged via the queue into main with commit af98091 Sep 20, 2024
35 of 36 checks passed
@zwang28 zwang28 deleted the wangzheng/compaction_ignore_safe_epoch branch September 20, 2024 07:38
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.

2 participants