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: deprecate max_committed_epoch of hummock version #18644

Merged
merged 7 commits into from
Sep 30, 2024

Conversation

wenym1
Copy link
Contributor

@wenym1 wenym1 commented Sep 23, 2024

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, the max_committed_epoch is marked as deprecated.

The only reason to keep it is only for backward-compatibility when upgrading from a old version that has not filled in the state_table_info yet to the current version. During such upgrade, we need to get the max_committed_epoch of the latest version, and therefore should still retain the code that maintain the previous max_committed_epoch.

Besides, for an empty cluster with no state table at all, we will handle the periodic barrier and call commit_epoch anyway because we can still bump up the max_committed_epoch. However, after we deprecate the max_committed_epoch, commit_epoch on an empty cluster becomes meaningless, because there is no table to bump up the committed_epoch. Therefore, in this PR, we change to skip and do not inject a periodic barrier when the cluster is empty. In this way, we can ensure that in each commit_epoch, there are some tables to bump up the committed_epoch.

Moreover, previously we use the committed_epoch as the sub_level_id of the sub level of the newly added sub level. In this PR, we decouple the two concepts, and will use the latest_sub_level_id + 1 as the sub_level_id of newly added sub level.

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 changed the base branch from yiming/no-frontend-max-committed-epoch to main September 27, 2024 05:45
@wenym1 wenym1 changed the base branch from main to yiming/no-frontend-max-committed-epoch September 27, 2024 07:00
Base automatically changed from yiming/no-frontend-max-committed-epoch to main September 29, 2024 06:20
@wenym1 wenym1 force-pushed the yiming/deprecate-max-committed-epoch branch from 8afc2d5 to f47530f Compare September 29, 2024 06:24
@wenym1 wenym1 added ci/run-backfill-tests ci/run-backwards-compat-tests Run backwards compatibility tests in your PR. labels Sep 29, 2024
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, thanks for the PR

.last()
.map(|level| level.sub_level_id + 1)
})
.unwrap_or(committed_epoch);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we decouple sub_level_id from epoch, can we default to using a constant as the default value (e.g. 1)

@zwang28 @hzxa21

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we accept sub-level-id to go backward? Example:
At T1, we create sub-level with id=1
At T2, sub-level id=1 is compacted to base level and all sub-levels are removed
At T3, we create a new sub-level again with id=1

Copy link
Member

@yezizp2012 yezizp2012 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

LGTM

src/meta/src/hummock/manager/commit_epoch.rs Show resolved Hide resolved
if let Some(committed_epoch) = committed_epoch {
for (table_id, info) in version.state_table_info.info() {
assert_eq!(
info.committed_epoch, committed_epoch,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to confirm: the reason why this assertion is valid is because snapshot backfill is non-resumable and tables with fake epochs will be cleaned. In the future with partial ckpt recovery, this assertion will not longer hold.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's only a sanity check for current implementation.

.last()
.map(|level| level.sub_level_id + 1)
})
.unwrap_or(committed_epoch);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we accept sub-level-id to go backward? Example:
At T1, we create sub-level with id=1
At T2, sub-level id=1 is compacted to base level and all sub-levels are removed
At T3, we create a new sub-level again with id=1

@wenym1 wenym1 added this pull request to the merge queue Sep 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Sep 30, 2024
@wenym1 wenym1 enabled auto-merge September 30, 2024 09:29
@wenym1 wenym1 added this pull request to the merge queue Sep 30, 2024
Merged via the queue into main with commit fae0201 Sep 30, 2024
33 of 35 checks passed
@wenym1 wenym1 deleted the yiming/deprecate-max-committed-epoch branch September 30, 2024 09:30
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