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: refactor source executor (part 2) #15104

Merged
merged 3 commits into from
Feb 19, 2024

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Feb 18, 2024

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

What's changed and what's your intention?

This refactor reduces the target_state variable passed around. It's hard to understand and error-prone since we already have the fields have similar meanings.

We update the states immediately instead.

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.

@xxchan xxchan changed the title refactor: refactor source executor refactor: refactor source executor (part 2) Feb 18, 2024
@xxchan xxchan marked this pull request as ready for review February 18, 2024 03:38
Comment on lines -181 to -183
if states.is_empty() {
// TODO should be a clear Error Code
bail!("states require not null");
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't find this check useful?

Copy link
Contributor

Choose a reason for hiding this comment

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

it is ok to remove the check, no need any more

Comment on lines -311 to -332
if let Some(target_splits) = target_state {
let target_split_ids: HashSet<_> =
target_splits.iter().map(|split| split.id()).collect();

cache.retain(|split| target_split_ids.contains(&split.id()));

let dropped_splits = core
.latest_split_info
.extract_if(|split_id, _| !target_split_ids.contains(split_id))
.map(|(_, split)| split)
.collect_vec();

if should_trim_state && !dropped_splits.is_empty() {
// trim dropped splits' state
core.split_state_store.trim_state(&dropped_splits).await?;
}

core.latest_split_info = target_splits
.into_iter()
.map(|split| (split.id(), split))
.collect();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This section is moved to update_state_if_changed now

@xxchan
Copy link
Member Author

xxchan commented Feb 18, 2024

Oops, deterministic test failed

// existing split, no change, clone from cache
target_state.push(s.clone())
for (split_id, split) in target_splits {
if let Some(s) = core.latest_split_info.get(&split_id) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This line is a minor change. I think using latest_split_info is better than updated_splits_in_epoch here.

Base automatically changed from 02-16-refactor_refactor_SourceExecutor to main February 19, 2024 05:46
@xxchan xxchan force-pushed the 02-18-refactor_refactor_source_executor branch from d42f9c7 to 6975649 Compare February 19, 2024 06:05
Copy link
Contributor

@tabVersion tabVersion left a comment

Choose a reason for hiding this comment

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

LGTM

@xxchan xxchan enabled auto-merge February 19, 2024 10:04
@xxchan xxchan added this pull request to the merge queue Feb 19, 2024
Merged via the queue into main with commit 2592880 Feb 19, 2024
27 of 28 checks passed
@xxchan xxchan deleted the 02-18-refactor_refactor_source_executor branch February 19, 2024 10:33
TennyZhuang added a commit that referenced this pull request Feb 21, 2024
TennyZhuang added a commit that referenced this pull request Feb 21, 2024
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