-
Notifications
You must be signed in to change notification settings - Fork 317
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 alter twcs compression options #4939
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
0ff73fa
to
1e58c0c
Compare
1e58c0c
to
e146d81
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4939 +/- ##
==========================================
- Coverage 84.05% 83.78% -0.27%
==========================================
Files 1142 1143 +1
Lines 211545 212050 +505
==========================================
- Hits 177804 177667 -137
- Misses 33741 34383 +642 |
src/store-api/src/region_request.rs
Outdated
value: humantime::format_duration(*duration).to_string(), | ||
}, | ||
ChangeOption::TwscMaxActiveWindowRuns(runs) => ChangeTableOption { | ||
key: "compaction.twcs.max_active_window_runs".to_string(), |
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.
Can we extract these string literals to consts? They appear multiple times in codebase.
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.
yep its a good idea
src/store-api/src/region_request.rs
Outdated
}), | ||
}, | ||
ChangeOption::TwscRemoteCompaction(flag) => ChangeTableOption { | ||
key: "compaction.twcs.remote_compaction".to_string(), |
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.
Not sure if this option can be modified dynamically? @zyy
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.
I see i left this option out in this new update
src/mito2/src/worker/handle_alter.rs
Outdated
let Twcs(options) = current_options.compaction; | ||
let runs = runs.unwrap_or(TwcsOptions::default().max_active_window_runs); | ||
info!( | ||
"Update region compaction.twcs.max_active_window_runs: {}, previous: {} new: {}", | ||
region.region_id, options.max_active_window_runs, runs | ||
); | ||
let mut new_option = options.clone(); | ||
new_option.max_active_window_runs = runs; | ||
current_options.compaction = Twcs(new_option) |
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.
Can we avoid the clone here?
let Twcs(options) = current_options.compaction; | |
let runs = runs.unwrap_or(TwcsOptions::default().max_active_window_runs); | |
info!( | |
"Update region compaction.twcs.max_active_window_runs: {}, previous: {} new: {}", | |
region.region_id, options.max_active_window_runs, runs | |
); | |
let mut new_option = options.clone(); | |
new_option.max_active_window_runs = runs; | |
current_options.compaction = Twcs(new_option) | |
let Twcs(options) = &mut current_options.compaction; | |
let runs = runs.unwrap_or(TwcsOptions::default().max_active_window_runs); | |
info!( | |
"Update region compaction.twcs.max_active_window_runs: {}, previous: {} new: {}", | |
region.region_id, options.max_active_window_runs, runs | |
); | |
options.max_active_window_runs = runs; |
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.
good call fixed it
e146d81
to
39f64b6
Compare
39f64b6
to
42db982
Compare
@@ -661,23 +667,126 @@ impl From<v1::ChangeColumnType> for ChangeColumnType { | |||
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] | |||
pub enum ChangeOption { | |||
TTL(Duration), | |||
TwscMaxActiveWindowRuns(Option<usize>), |
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.
What about changing these variants into one
Twcs(String)
The String
value is the option name such as compaction.twcs.max_active_window_runs
etc.
I think it looks much better and we can add new options in the future without adding new variant of ChangeOption
.
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.
I think the draw back would be that we cannot validate the type of value at storage api layer - i.e user can pass max_active_window_runs='abcde' and this will error out at mito engine code path (where we handle the alter options).
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.
I think the draw back would be that we cannot validate the type of value at storage api layer - i.e user can pass max_active_window_runs='abcde' and this will error out at mito engine code path (where we handle the alter options).
We can match the option to verify its validity, as the next comment explains.
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.
ah i see great call
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.
I took a try at implement this approach, I had a few concerns:
- we also need the value of the change, the enum would look like Twcs(String, String)
- the second comments suggest that we match and validate values at Mito side when handling the alter request which will cause some drift in logics. (i.e. ttl change values are parsed and validated on building the request and it will return a metadata error - InvalidRegionOptionChangeRequest).
This is a draft of the working attempt https://github.com/GreptimeTeam/greptimedb/pull/4965/files if you like it i can push to this branch.
@@ -167,6 +169,67 @@ impl<S> RegionWorkerLoop<S> { | |||
current_options.ttl = Some(new_ttl); | |||
} | |||
} | |||
ChangeOption::TwscMaxActiveWindowRuns(runs) => { |
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.
If we change all these variants into Twcs(String)
, then we can refactor these match clauses into:
ChangeOption::Twcs(options) =>
{
match options.as_str() => {
"compaction.twcs.max_active_window_runs" => { .. }
......
}
}
the new approach look cleaner going to close this one in favor of |
Refer to a related PR or issue link (optional)
#4905
What's changed and what's your intention?
support alter twcs compaction options on sql level
!!! DO NOT LEAVE THIS BLOCK EMPTY !!!
Please explain IN DETAIL what the changes are in this PR and why they are needed:
expand alter table set options to include twcs compaction options.
Summarize your change (mandatory)
The approach here is to expand ChangeOption enum with twcs compaction options.
The key and value type is validated at store-api end.
If value is missing (empty string) it will be set with default value.
Changes will be reflected on show create table statements.
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)
Checklist