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

fix(meta): locate upstream source fragment correctly for SourceBackfill #19564

Merged
merged 5 commits into from
Nov 27, 2024

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Nov 25, 2024

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

What's changed and what's your intention?

fix #19563

Previously, we use upstream_fragment_ids and upstream_actor_ids in the Fragment and Actor models directly to find the upstream Source of the SourceBackfill.

The problem is that we assumed the fragment for SourceBackfill have only one upstream fragment, which is false. There could be other Merge nodes in the fragment, thus other upstream fragments. DynamicFilter is one example where the assumption doesn't hold.

In this PR, we change to use upstream_fragment_id in the Merge node.
Regarding upstream_actor_id, it's a little troublesome. Seem code and comments for more details.

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 Xxchan/closed narwhal fix: locate upstream source fragment correctly for SourceBackfill Nov 25, 2024
@github-actions github-actions bot added type/fix Bug fix and removed Invalid PR Title labels Nov 25, 2024
@graphite-app graphite-app bot requested a review from a team November 25, 2024 15:01
@xxchan xxchan force-pushed the xxchan/closed-narwhal branch 2 times, most recently from 9c3ee4b to 6b449e0 Compare November 25, 2024 17:07
Signed-off-by: xxchan <[email protected]>

add test

Signed-off-by: xxchan <[email protected]>

fix scaling

Signed-off-by: xxchan <[email protected]>

fix  test

Signed-off-by: xxchan <[email protected]>

fix

Signed-off-by: xxchan <[email protected]>
@xxchan xxchan force-pushed the xxchan/closed-narwhal branch from ad2e783 to 93e7c2b Compare November 26, 2024 13:56
@xxchan xxchan changed the title fix: locate upstream source fragment correctly for SourceBackfill fix(meta): locate upstream source fragment correctly for SourceBackfill Nov 27, 2024
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!

Comment on lines 298 to 300
/// Note: `merge.upstream_actor_id` need to be used with caution.
/// DO NOT USE if the `StreamNode` is from `Fragment` meta model.
/// OK to use if the `StreamNode` is from `TableFragments` proto.
Copy link
Member

Choose a reason for hiding this comment

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

Why, can you elaborate more? This sounds type-unsafe.

Copy link
Member Author

Choose a reason for hiding this comment

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

mentioned here

/// Note: the `StreamNode` is different from the final plan node used by actors.
/// Specifically, `Merge` nodes' `upstream_actor_id` will be filled. (See `compose_fragment`)
pub stream_node: StreamNode,

Previously we store TableFragments containing Actors containing (multiple copies of) StreamNode (but the only difference is MergeNode's upstream_actor_id).

Now we just store Fragment containing one StreamNode, and upstream_actor_id is not filled.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

Copy link
Contributor

Choose a reason for hiding this comment

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

The StreamNode in a Fragment is merely a template. This is likely to be modified or restricted from direct use in the future. All actor relationships should be determined through the upstream_fragment_id in the fragment table, along with the actor and actor dispatcher tables.

let inner = self.inner.read().await;
let txn = inner.db.begin().await?;
let fragment = Fragment::find_by_id(fragment_id)
Copy link
Member

@BugenZhao BugenZhao Nov 27, 2024

Choose a reason for hiding this comment

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

Can we then still use fragment.upstream_fragment_id but check the fragment_type_mask to filter out the desired one?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will rely on a new assumption that the upstream fragments can only have 1 Source fragment. It seems safer, but I'd prefer not to rely on it.

Signed-off-by: xxchan <[email protected]>
Signed-off-by: xxchan <[email protected]>
@xxchan
Copy link
Member Author

xxchan commented Nov 27, 2024

@BugenZhao
I managed to removing the _do_not_use. It looks slightly better now.

Copy link
Member

@fuyufjh fuyufjh 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 requested a review from BugenZhao November 27, 2024 08:11
Copy link
Contributor

@shanicky shanicky left a comment

Choose a reason for hiding this comment

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

lgtm

Signed-off-by: xxchan <[email protected]>
@xxchan xxchan added this pull request to the merge queue Nov 27, 2024
Merged via the queue into main with commit c45327b Nov 27, 2024
34 of 35 checks passed
@xxchan xxchan deleted the xxchan/closed-narwhal branch November 27, 2024 10:20
xxchan added a commit that referenced this pull request Nov 28, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 28, 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.

shared source doesn't work with dynamic filter
5 participants