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(meta): refactor how upstream fragment is handled when creating stream job #14510

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Jan 11, 2024

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

What's changed and what's your intention?

Mainly because when I trying to add source backfill, I found it's not easy to understand how to handle TableJobType correctly.

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.

Comment on lines -29 to -30
#[strum_discriminants(name(DdlType))]
#[strum_discriminants(vis(pub))]
Copy link
Member Author

Choose a reason for hiding this comment

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

A step back... 🤣

@xxchan xxchan force-pushed the 01-11-chore_add_some_comments_for_creating_streaming_job branch from 494ead9 to b5c248d Compare January 11, 2024 09:17
@xxchan xxchan changed the title chore: add some comments for creating streaming job refactor(meta): make stream graph building more reasonable Jan 11, 2024
// handle MV on MV

// Build the extra edges between the upstream `Materialize` and the downstream `StreamScan`
// of the new materialized view.
let mview_fragment = upstream_root_fragments
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 think this can also be source_fragment for MV on backfill-able source later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Wait, isn't this also the same for CDC table..?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, the only difference is how to get output_indices, we have as_materialize in this branch.

@xxchan xxchan force-pushed the 01-11-chore_add_some_comments_for_creating_streaming_job branch from b5c248d to 9985531 Compare January 11, 2024 09:30
@xxchan xxchan changed the title refactor(meta): make stream graph building more reasonable refactor(meta): refactor how upstream fragment is handled when creating stream job Jan 11, 2024
f.fragment_type_mask & PbFragmentTypeFlag::Mview as i32 != 0
}
fragments.retain(|f| {
f.fragment_type_mask & PbFragmentTypeFlag::Source as i32 != 0
Copy link
Contributor

Choose a reason for hiding this comment

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

A normal table also contains a Source fragment which should not filtered as the root fragment. That's why e2e fails I think.

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 makes me think what to do for MV on reuseable source..

Copy link
Member Author

@xxchan xxchan Jan 12, 2024

Choose a reason for hiding this comment

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

I came up with a solution: search for Source fragment only if there's no Mview.

It doesn't work for MV with an upstream MV and an upstream source.

It should be: For each upstream table id, if it doesn't have a MV fragment, then look for its source fragment.

Copy link
Member Author

@xxchan xxchan Jan 12, 2024

Choose a reason for hiding this comment

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

Actually we are looking for the bottom-most node in the graph. 🤔

Oh, that's why it's called "Root fragment" 🤣

@@ -668,6 +675,9 @@ impl CompleteStreamFragmentGraph {

(mview_id, edge)
}
DdlType::Source | DdlType::Table(_) => {
Copy link
Member

Choose a reason for hiding this comment

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

Is this branch reachable for schema change on a sink-into table?

Copy link
Member Author

@xxchan xxchan Jan 12, 2024

Choose a reason for hiding this comment

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

I don't get it. Can you elaborate?

Copy link
Member

Choose a reason for hiding this comment

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

#14417 Oh, it's a TODO now. Never mind.

@xxchan xxchan force-pushed the 01-11-chore_add_some_comments_for_creating_streaming_job branch from 9985531 to 2aaa7f5 Compare January 12, 2024 01:12
@xxchan xxchan requested review from StrikeW and BugenZhao January 12, 2024 03:18
Comment on lines +1415 to +1416
// look for Source fragment if there's no MView fragment
fragments.insert(table_id, fragment);
Copy link
Member

Choose a reason for hiding this comment

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

This is quite counter-intu😄tive. May add some comments to show that this is for Source job?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, it's already on pub async fn get_upstream_root_fragments.

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!

@xxchan xxchan added this pull request to the merge queue Jan 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 12, 2024
@xxchan xxchan added this pull request to the merge queue Jan 12, 2024
Merged via the queue into main with commit 681c226 Jan 12, 2024
29 of 30 checks passed
@xxchan xxchan deleted the 01-11-chore_add_some_comments_for_creating_streaming_job branch January 12, 2024 08:06
Comment on lines +1052 to +1053
// look for Source fragment if there's no MView fragment
_ = fragments.try_insert(fragment.job_id, fragment);
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 thought I made a mistake, then I finally noticed it is try_insert 😅

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.

4 participants