-
Notifications
You must be signed in to change notification settings - Fork 599
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: support schedule/reschedule resource group #19955
Merged
Merged
Changes from 7 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e5c786f
Add job label to StreamingJob and related changes
shanicky 10bf04c
Add `resource_group` to `make_cluster_info` in `test_fragmenter.rs`, …
shanicky 5b62d2d
Merge remote-tracking branch 'origin/main' into peng/schedule-resourc…
shanicky 6e69c23
Clean up Rust test: remove unused imports, debug prints, and redundan…
shanicky 2cf6546
Refactor `scale.rs` for clarity; optimize string handling in `resourc…
shanicky 7b4f5e1
Merge remote-tracking branch 'origin/main' into peng/schedule-resourc…
shanicky ddc4bdc
Merge branch 'main' into peng/schedule-resource-group
shanicky 1fa09af
Fix import formatting in recovery.rs and ddl_controller.rs
shanicky 03e6f24
Update copyright year to 2025 in alter_resource_group.rs
shanicky 869b288
Refactor DB handling in `alter_resource_group.rs`; clean imports in `…
shanicky 6286128
Add resource group handling in MV creation; check streaming config; a…
shanicky 71a8479
Update copyright year to 2025 in resource_group.rs (simulations integ…
shanicky cbe2678
Merge branch 'main' into peng/schedule-resource-group
shanicky 7fb0c3d
Add compute_resource_groups field for fine-grained resource management
shanicky 445716e
Merge branch 'main' into peng/schedule-resource-group
shanicky 8a10e86
Update Cargo.toml
shanicky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright 2024 RisingWave Labs | ||
shanicky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use pgwire::pg_response::StatementType; | ||
use risingwave_common::bail; | ||
use risingwave_sqlparser::ast::{ObjectName, SetVariableValue, SetVariableValueSingle, Value}; | ||
|
||
use super::{HandlerArgs, RwPgResponse}; | ||
use crate::catalog::root_catalog::SchemaPath; | ||
use crate::catalog::table_catalog::TableType; | ||
use crate::error::{ErrorCode, Result}; | ||
use crate::Binder; | ||
|
||
pub async fn handle_alter_resource_group( | ||
handler_args: HandlerArgs, | ||
obj_name: ObjectName, | ||
resource_group: Option<SetVariableValue>, | ||
stmt_type: StatementType, | ||
deferred: bool, | ||
) -> Result<RwPgResponse> { | ||
let session = handler_args.session; | ||
let db_name = session.database(); | ||
let (schema_name, real_table_name) = | ||
Binder::resolve_schema_qualified_name(db_name, obj_name.clone())?; | ||
let search_path = session.config().search_path(); | ||
let user_name = &session.auth_context().user_name; | ||
let schema_path = SchemaPath::new(schema_name.as_deref(), &search_path, user_name); | ||
|
||
let table_id = { | ||
let reader = session.env().catalog_reader().read_guard(); | ||
|
||
match stmt_type { | ||
StatementType::ALTER_MATERIALIZED_VIEW => { | ||
let (table, schema_name) = | ||
reader.get_created_table_by_name(db_name, schema_path, &real_table_name)?; | ||
|
||
match (table.table_type(), stmt_type) { | ||
(TableType::MaterializedView, StatementType::ALTER_MATERIALIZED_VIEW) => {} | ||
_ => { | ||
return Err(ErrorCode::InvalidInputSyntax(format!( | ||
"cannot alter resource group of {} {} by {}", | ||
table.table_type().to_prost().as_str_name(), | ||
table.name(), | ||
stmt_type, | ||
)) | ||
.into()); | ||
} | ||
} | ||
|
||
session.check_privilege_for_drop_alter(schema_name, &**table)?; | ||
table.id.table_id() | ||
} | ||
_ => bail!( | ||
"invalid statement type for alter resource group: {:?}", | ||
stmt_type | ||
), | ||
} | ||
}; | ||
|
||
let resource_group = match resource_group { | ||
None => None, | ||
Some(SetVariableValue::Single(SetVariableValueSingle::Ident(ident))) => { | ||
Some(ident.real_value()) | ||
} | ||
Some(SetVariableValue::Single(SetVariableValueSingle::Literal( | ||
Value::SingleQuotedString(v), | ||
))) => Some(v), | ||
_ => { | ||
return Err(ErrorCode::InvalidInputSyntax( | ||
"target parallelism must be a valid number or adaptive".to_owned(), | ||
) | ||
.into()); | ||
} | ||
}; | ||
|
||
let mut builder = RwPgResponse::builder(stmt_type); | ||
|
||
let catalog_writer = session.catalog_writer()?; | ||
catalog_writer | ||
.alter_resource_group(table_id, resource_group, deferred) | ||
.await?; | ||
|
||
if deferred { | ||
builder = builder.notice("DEFERRED is used, please ensure that automatic parallelism control is enabled on the meta, otherwise, the alter will not take effect.".to_owned()); | ||
} | ||
|
||
Ok(builder.into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
will be reverted once approved