-
Notifications
You must be signed in to change notification settings - Fork 460
feat: Allow ALTER TABLE to modify the skip_wal option dynamically #7550
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?
Changes from 7 commits
57608d7
3de4ad8
353853f
93c37b3
d0c0ad0
1432e2e
1a641b0
4f8ffde
21fb8ce
cd160e5
76b89c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -283,13 +283,43 @@ impl AlterTableProcedure { | |
| }; | ||
|
|
||
| // Safety: region distribution is set in `submit_alter_region_requests`. | ||
| // Check if skip_wal changed and update WAL options if needed | ||
| let current_skip_wal = table_info_value.table_info.meta.options.skip_wal; | ||
|
||
| let new_skip_wal = new_info.meta.options.skip_wal; | ||
| let new_region_wal_options = | ||
| if current_skip_wal != new_skip_wal && self.data.region_distribution.is_some() { | ||
| // Get region numbers from region_distribution | ||
| let region_distribution = self.data.region_distribution.as_ref().unwrap(); | ||
| let region_numbers: Vec<_> = region_distribution | ||
| .values() | ||
| .flat_map(|region_role_set| { | ||
| region_role_set | ||
| .leader_regions | ||
| .iter() | ||
| .chain(region_role_set.follower_regions.iter()) | ||
| .copied() | ||
| }) | ||
| .collect(); | ||
| // Allocate new WAL options based on skip_wal | ||
| Some( | ||
| self.context | ||
| .table_metadata_allocator | ||
| .wal_options_allocator() | ||
| .allocate(®ion_numbers, new_skip_wal) | ||
| .await?, | ||
| ) | ||
| } else { | ||
| None | ||
| }; | ||
|
|
||
| self.executor | ||
| .on_alter_metadata( | ||
| &self.context.table_metadata_manager, | ||
| table_info_value, | ||
| self.data.region_distribution.as_ref(), | ||
| new_info.into(), | ||
| &self.data.column_metadatas, | ||
| new_region_wal_options, | ||
| ) | ||
| .await?; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ use std::sync::Arc; | |
| use common_base::readable_size::ReadableSize; | ||
| use common_telemetry::info; | ||
| use common_telemetry::tracing::warn; | ||
| use common_wal::options::WalOptions; | ||
| use humantime_serde::re::humantime; | ||
| use snafu::{ResultExt, ensure}; | ||
| use store_api::logstore::LogStore; | ||
|
|
@@ -229,6 +230,24 @@ impl<S: LogStore> RegionWorkerLoop<S> { | |
| ); | ||
| } | ||
| } | ||
| SetRegionOption::SkipWal(skip_wal) => { | ||
|
||
| info!( | ||
| "Update region skip_wal: {}, previous: {:?} new: {}", | ||
| region.region_id, current_options.wal_options, skip_wal | ||
| ); | ||
| if skip_wal { | ||
| // Disable WAL by setting to Noop | ||
| current_options.wal_options = WalOptions::Noop; | ||
| } else { | ||
| // Enable WAL: restore to default (RaftEngine) | ||
| // TODO: In distributed mode, this should be allocated by metasrv, | ||
| // but for simplicity, we use RaftEngine as default here. | ||
| // The actual WAL options will be persisted in metasrv. | ||
| // We should read the correct WAL options from DatanodeTableValue | ||
| // or pass them through the AlterRegionRequest. | ||
| current_options.wal_options = WalOptions::RaftEngine; | ||
|
||
| } | ||
| } | ||
| } | ||
| } | ||
| region.version_control.alter_options(current_options); | ||
|
|
@@ -264,6 +283,13 @@ fn new_region_options_on_empty_memtable( | |
|
|
||
| current_options.sst_format = Some(new_format); | ||
| } | ||
| SetRegionOption::SkipWal(skip_wal) => { | ||
|
||
| if *skip_wal { | ||
| current_options.wal_options = WalOptions::Noop; | ||
| } else { | ||
| current_options.wal_options = WalOptions::RaftEngine; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Some(current_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.
This change increases curl timeouts from 10s connection timeout with 3 retries to 30s connection timeout, 60s max time, with 3 retries. While this may improve reliability, this change appears unrelated to the skip_wal feature. Consider moving this to a separate PR or explaining its relevance to this feature in the PR description.