-
Notifications
You must be signed in to change notification settings - Fork 700
feat: add SQL support to alter fragment parallelism #23523
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
base: main
Are you sure you want to change the base?
Conversation
a6d70dd to
0e7e38f
Compare
a7b7a7f to
100e4f7
Compare
Enable fine-grained scaling by allowing users to adjust parallelism for individual streaming fragments using SQL. Improves operational flexibility and user experience. - Add Protobuf and gRPC support for fragment parallelism changes - Extend SQL parser and AST for ALTER FRAGMENT SET PARALLELISM - Implement frontend handler and meta client logic for new operation - Update meta service, controller, and stream manager to reschedule fragments online with new parallelism - Enhance error handling and test utilities for new trait method Signed-off-by: Shanicky Chen <peng@risingwave-labs.com>
baacc40 to
6d99ec1
Compare
|
Looks like this PR extends new SQL syntax or updates existing ones. Make sure that:
|
Remove support for parsing "BACKFILL_RATE_LIMIT" and require only "RATE_LIMIT" after "SET" to streamline the parsing logic. - Eliminate deprecated "BACKFILL_RATE_LIMIT" keyword handling - Enforce consistent syntax by accepting only "RATE_LIMIT" - Reduce complexity and potential parsing errors Signed-off-by: Peng Chen <peng@risingwave-labs.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for altering fragment parallelism through a new ALTER FRAGMENT <id> SET PARALLELISM = <value> SQL command. This extends the existing ALTER FRAGMENT functionality, which previously only supported altering backfill rate limits.
Key changes:
- Added
ALTER_FRAGMENTstatement type to the PostgreSQL wire protocol response types - Extended the SQL parser to handle
SET PARALLELISMoperation alongside existingSET RATE_LIMIToperation - Implemented backend handlers and RPC endpoints for altering fragment parallelism
- Added test coverage for the new SQL syntax
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/pgwire/src/pg_response.rs | Adds ALTER_FRAGMENT statement type enum variant and mapping |
| src/sqlparser/src/ast/ddl.rs | Adds SetParallelism variant to AlterFragmentOperation enum with Display impl |
| src/sqlparser/src/parser.rs | Extends parser to handle SET PARALLELISM in addition to SET RATE_LIMIT |
| src/sqlparser/tests/sqlparser_common.rs | Adds test for parsing ALTER FRAGMENT SET PARALLELISM syntax |
| proto/ddl_service.proto | Defines new RPC messages for alter fragment parallelism requests |
| src/rpc_client/src/meta_client.rs | Adds client method for calling alter fragment parallelism RPC |
| src/meta/service/src/ddl_service.rs | Implements RPC service handler for alter fragment parallelism |
| src/meta/src/rpc/ddl_controller.rs | Adds DDL controller method to delegate to stream manager |
| src/meta/src/stream/stream_manager.rs | Implements core logic for rescheduling fragments with new parallelism |
| src/meta/src/stream/scale.rs | Improves error message for missing fragment entry in reschedule request |
| src/frontend/src/handler/mod.rs | Routes ALTER FRAGMENT SET PARALLELISM statements to appropriate handler |
| src/frontend/src/handler/alter_parallelism.rs | Implements frontend handler for alter fragment parallelism |
| src/frontend/src/meta_client.rs | Adds frontend meta client interface method |
| src/frontend/src/test_utils.rs | Adds unimplemented stub for mock frontend meta client |
Comments suppressed due to low confidence (2)
src/sqlparser/src/parser.rs:3835
- The error message is redundant with the word 'expected' appearing twice. Change to 'RATE_LIMIT after SET' or 'expected RATE_LIMIT or PARALLELISM after ALTER FRAGMENT SET'.
if !self.parse_word("RATE_LIMIT") {
return self.expected("expected RATE_LIMIT after SET");
src/sqlparser/src/parser.rs:3838
- The error message should be consistent with the full context. Change to 'TO or = after ALTER FRAGMENT SET RATE_LIMIT' to match the pattern used in line 3819 and other similar error messages in the file.
if self.expect_keyword(Keyword::TO).is_err() && self.expect_token(&Token::Eq).is_err() {
return self.expected("TO or = after RATE_LIMIT");
- Change SQL parser test to use `SET PARALLELISM TO` syntax matching updated grammar - Add integration tests verifying ALTER FRAGMENT parallelism changes under different cluster configs - Ensure fragment parallelism updates persist and behave correctly with and without shuffle - Register new test module for CI coverage and stability - Improve test coverage to prevent regressions in fragment scaling and metadata updates Signed-off-by: Peng Chen <peng@risingwave-labs.com>
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Summary
This PR introduces SQL support for altering the parallelism of streaming fragments via the new
ALTER FRAGMENT ... SET PARALLELISMstatement, enabling fine-grained runtime adjustment of fragment execution. It extends the SQL, frontend, meta service, and stream manager layers to support direct fragment-level parallelism changes, and refactors related APIs for improved clarity and maintainability.Details
ALTER FRAGMENT <fragment_id> SET PARALLELISM = <value>, allowing users to modify fragment parallelism (fixed or adaptive) at runtime for specific fragments.Checklist
Documentation
Release note
Added an SQL interface for
alter fragment {fragmnt_id} set parallelism = {parallelism}