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: Correctly handle the Parallelism inference under the DefaultParallelism configuration. #15543

Merged
merged 4 commits into from
Mar 8, 2024

Conversation

shanicky
Copy link
Contributor

@shanicky shanicky commented Mar 8, 2024

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

What's changed and what's your intention?

This PR correctly handles the compatibility between default parallelism and table parallelism.

DefaultParallelism::Full DefaultParallelism::Default(n)
Adaptive Adaptive, all Fixed, n
Fixed(m) Fixed(m), m Fixed, m

And during restarts, it automatically scales the logic to address the impacts that may arise from old versions. For instance, when the default parallelism is set to n, older versions may still be set to Adaptive mode. This PR, upon startup, will determine if the actual parallelism is n and will update it to Fixed(n).

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.

@github-actions github-actions bot added the type/fix Bug fix label Mar 8, 2024
@neverchanje neverchanje requested a review from hzxa21 March 8, 2024 06:45
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, @neverchanje PTAL.

@neverchanje
Copy link
Contributor

neverchanje commented Mar 8, 2024

DefaultParallelism::Full DefaultParallelism::Default(n)
Adaptive Fixed(n) for creating MV, while remaining Adaptive for existing MV
Fixed(m) Fixed(m)

If a users explicitly alter a MV to adaptive, with default_parallelism preconfigured as n in the meanwhile, the parallelism should be changed to adaptive.

// If it's lower, we'll set it to Fixed.
// If it was previously set to Adaptive, but the default_parallelism in the configuration isn’t Full,
// and it matches the actual fragment parallelism, in this case, it will be handled by downgrading to Fixed.
fn derive_target_parallelism(
Copy link
Contributor

@neverchanje neverchanje Mar 8, 2024

Choose a reason for hiding this comment

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

Is this function only called when MV is being created? alter mv and create mv are two different handling paths. Only create mv should evaluate default_parallelism, alter mv should not.

The logic is pretty simple from my understanding.

// Let's divide the handling into two phases:
fn create_mv() {
  // handle `default_parallelism` first.
  let mut parallelism = match config.default_parallelism {
    Some(n) => Fixed(n)
    None => Adaptive
  };
  // Evaluate the sesssion variable  "streaming_parallelism".
  if let Some(p) = session_variable.streaming_parallelism {
    parallelism = p;
  }
}

fn alter_mv(p: TableParallelism) {
  // `p` will be the target parallelism, no matter what value `default_parallelism` is.
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This modification is made to handle offline scaling during startup recovery, addressing the situation in version 1.7 where new creations using default parallelism with an adaptive policy might exist. This aims to prevent a mass scale-out occurrence immediately after going live.

Copy link
Contributor

@neverchanje neverchanje Mar 8, 2024

Choose a reason for hiding this comment

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

new creations using default parallelism

It sounds good.

I am not familar with the code so I cannot tell if it's correct. Maybe you can manually test it, and make sure:

  1. alter mv will apply regardless of default_parallelism .
  2. Restarting the cluster will not change the parallelism of existing materialized views back to default_parallelism.

@shanicky shanicky added this pull request to the merge queue Mar 8, 2024
Merged via the queue into main with commit e0f305e Mar 8, 2024
28 of 29 checks passed
@shanicky shanicky deleted the peng/fix-default-as-fixed branch March 8, 2024 10:12
shanicky added a commit that referenced this pull request Mar 8, 2024
shanicky added a commit that referenced this pull request Mar 8, 2024
shanicky added a commit that referenced this pull request Mar 8, 2024
shanicky added a commit that referenced this pull request Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants