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

feat(frontend): support alter source pause/resume #19636

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

lyang24
Copy link
Contributor

@lyang24 lyang24 commented Dec 2, 2024

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

What's changed and what's your intention?

Please do not leave this empty!

Please explain IN DETAIL what the changes are in this PR and why they are needed:

  • Summarize your change (mandatory)
    Support alter source pause or resume syntax sugar by setting the rate limit to 0 on pause or to cancel rate limit on resume. Please not PAUSE/ RESUME only works when the source haven't configure the rate limit.
  • How does this PR work? Need a brief introduction for the changed logic (optional)
  • Describe clearly one logical change and avoid lazy messages (optional)
  • Describe any limitations of the current code (optional)
  • Refer to a related PR or issue link (optional)
    feat: alter source pause/resume #19181

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

Public Preview: Do note that the structure and format of ALTER SOURCE PAUSE/ RESUME is considered unstable, and may change overtime.

After this PR, two new alter source syntax will be supported.

ALTER SOURCE <name> PAUSE; to pause processing stream from source.
ALTER SOURCE <name> RESUME; to continue processing stream from source.

@kwannoel kwannoel changed the title feat(front): support alter source pause/unpause feat(frontend): support alter source pause/unpause Dec 2, 2024
AlterSourceOperation::SetSourceRateLimit {
rate_limit: SOURCE_RATE_LIMIT_PAUSED,
}
} else if self.parse_keyword(Keyword::UNPAUSE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use ALTER SOURCE RESUME instead of "Unpause"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep fixed it everywhere

@lyang24 lyang24 force-pushed the alter_source_pause branch from df3418c to 4203597 Compare December 2, 2024 06:54
@lyang24 lyang24 changed the title feat(frontend): support alter source pause/unpause feat(frontend): support alter source pause/resume Dec 2, 2024
@tabVersion
Copy link
Contributor

Hi @lyang24 , thanks for your contribution.

ALTER SOURCE PAUSE; to pause processing stream from source.
ALTER SOURCE RESUME; to continue processing stream from source.

I have a question about the semantics here, please consider the following use case.

create source s .... ;

alter s set streaming_rate_limit to 100;
alter s pause; -- source stopped
alter s resume; -- source rate_limit set to unlimited rather than 100

Setting rate_limit here may abuse the pause/resume semantic.

cc @fuyufjh, what do you think of the proposed syntax?

@kwannoel
Copy link
Contributor

kwannoel commented Dec 2, 2024

Hi @lyang24 , thanks for your contribution.

ALTER SOURCE PAUSE; to pause processing stream from source.
ALTER SOURCE RESUME; to continue processing stream from source.

I have a question about the semantics here, please consider the following use case.

create source s .... ;

alter s set streaming_rate_limit to 100;
alter s pause; -- source stopped
alter s resume; -- source rate_limit set to unlimited rather than 100

Setting rate_limit here may abuse the pause/resume semantic.

cc @fuyufjh, what do you think of the proposed syntax?

We can ban alter source pause if source already has rate limit set. Likewise, alter source resume can be banned, unless rate limit is 0.

@lyang24
Copy link
Contributor Author

lyang24 commented Dec 2, 2024

Hi @lyang24 , thanks for your contribution.

ALTER SOURCE PAUSE; to pause processing stream from source.
ALTER SOURCE RESUME; to continue processing stream from source.

I have a question about the semantics here, please consider the following use case.

create source s .... ;

alter s set streaming_rate_limit to 100;
alter s pause; -- source stopped
alter s resume; -- source rate_limit set to unlimited rather than 100

Setting rate_limit here may abuse the pause/resume semantic.
cc @fuyufjh, what do you think of the proposed syntax?

We can ban alter source pause if source already has rate limit set. Likewise, alter source resume can be banned, unless rate limit is 0.

The challenge is - The sql parser doesn't know the current rate limit nor can it distinguish from pause or set source_rate_limit to 0. To achieve this we probably need to modify SetSourceRateLimit { rate_limit: i32 }, to something like SetSourceRateLimit { rate_limit: i32 , paused: bool}, and handle in the handle_alter_streaming_rate_limit. let me know if there are better approaches.

@tabVersion
Copy link
Contributor

@kwannoel We can ban alter source pause if source already has rate limit set. Likewise, alter source resume can be banned, unless rate limit is 0.

I am up for this idea.

@lyang24 lyang24 force-pushed the alter_source_pause branch 3 times, most recently from 42b594f to 15cbc6b Compare December 3, 2024 00:41
@lyang24 lyang24 marked this pull request as ready for review December 3, 2024 00:42
Copy link
Contributor

@kwannoel kwannoel 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 your work!

@lyang24 lyang24 force-pushed the alter_source_pause branch from 15cbc6b to 9a99b62 Compare December 3, 2024 01:11
@graphite-app graphite-app bot requested a review from a team December 3, 2024 01:48
@kwannoel kwannoel added this pull request to the merge queue Dec 3, 2024
Merged via the queue into risingwavelabs:main with commit 6f2d0c3 Dec 3, 2024
28 of 29 checks passed
@tabVersion tabVersion added type/feature user-facing-changes Contains changes that are visible to users labels Dec 3, 2024
|| (prev_limit != 0 && rate_limit == SOURCE_RATE_LIMIT_RESUMED)
{
return Err(InvalidInputSyntax(
"PAUSE or RESUME is invalid when the stream has pre configured ratelimit."
Copy link
Member

Choose a reason for hiding this comment

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

"PAUSE or RESUME is invalid when the stream has pre configured ratelimit. Just use SET source_rate_limit = 0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants