mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-04 20:32:56 +00:00
refactor: introduce common-wal to aggregate wal stuff (#3171)
* refactor: aggregate wal configs * refactor: move wal options to common-wal * chore: slim Cargo.toml * fix: add missing crates * fix: format * chore: update comments * chore: add testing feature gate for test_util * fix: apply suggestions from code review Co-authored-by: JeremyHi <jiachun_feng@proton.me> * fix: apply suggestions from code review * fix: compiling --------- Co-authored-by: JeremyHi <jiachun_feng@proton.me>
This commit is contained in:
@@ -30,6 +30,7 @@ common-recordbatch.workspace = true
|
||||
common-runtime.workspace = true
|
||||
common-telemetry.workspace = true
|
||||
common-test-util.workspace = true
|
||||
common-wal.workspace = true
|
||||
datanode = { workspace = true }
|
||||
datatypes.workspace = true
|
||||
dotenv = "0.15"
|
||||
|
||||
@@ -24,7 +24,6 @@ use catalog::kvbackend::{CachedMetaKvBackend, MetaKvBackend};
|
||||
use client::client_manager::DatanodeClients;
|
||||
use client::Client;
|
||||
use common_base::Plugins;
|
||||
use common_config::WalConfig;
|
||||
use common_grpc::channel_manager::{ChannelConfig, ChannelManager};
|
||||
use common_meta::heartbeat::handler::parse_mailbox_message::ParseMailboxMessageHandler;
|
||||
use common_meta::heartbeat::handler::HandlerGroupExecutor;
|
||||
@@ -33,10 +32,10 @@ use common_meta::kv_backend::etcd::EtcdStore;
|
||||
use common_meta::kv_backend::memory::MemoryKvBackend;
|
||||
use common_meta::kv_backend::KvBackendRef;
|
||||
use common_meta::peer::Peer;
|
||||
use common_meta::wal::WalConfig as MetaWalConfig;
|
||||
use common_meta::DatanodeId;
|
||||
use common_runtime::Builder as RuntimeBuilder;
|
||||
use common_test_util::temp_dir::create_temp_dir;
|
||||
use common_wal::config::{DatanodeWalConfig, MetaSrvWalConfig};
|
||||
use datanode::config::{DatanodeOptions, ObjectStoreConfig};
|
||||
use datanode::datanode::{Datanode, DatanodeBuilder, ProcedureConfig};
|
||||
use frontend::heartbeat::handler::invalidate_table_cache::InvalidateTableCacheHandler;
|
||||
@@ -77,8 +76,8 @@ pub struct GreptimeDbClusterBuilder {
|
||||
store_config: Option<ObjectStoreConfig>,
|
||||
store_providers: Option<Vec<StorageType>>,
|
||||
datanodes: Option<u32>,
|
||||
wal_config: WalConfig,
|
||||
meta_wal_config: MetaWalConfig,
|
||||
wal_config: DatanodeWalConfig,
|
||||
meta_wal_config: MetaSrvWalConfig,
|
||||
shared_home_dir: Option<Arc<TempDir>>,
|
||||
meta_selector: Option<SelectorRef>,
|
||||
}
|
||||
@@ -106,8 +105,8 @@ impl GreptimeDbClusterBuilder {
|
||||
store_config: None,
|
||||
store_providers: None,
|
||||
datanodes: None,
|
||||
wal_config: WalConfig::default(),
|
||||
meta_wal_config: MetaWalConfig::default(),
|
||||
wal_config: DatanodeWalConfig::default(),
|
||||
meta_wal_config: MetaSrvWalConfig::default(),
|
||||
shared_home_dir: None,
|
||||
meta_selector: None,
|
||||
}
|
||||
@@ -132,13 +131,13 @@ impl GreptimeDbClusterBuilder {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_wal_config(mut self, wal_config: WalConfig) -> Self {
|
||||
pub fn with_wal_config(mut self, wal_config: DatanodeWalConfig) -> Self {
|
||||
self.wal_config = wal_config;
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_meta_wal_config(mut self, wal_meta: MetaWalConfig) -> Self {
|
||||
pub fn with_meta_wal_config(mut self, wal_meta: MetaSrvWalConfig) -> Self {
|
||||
self.meta_wal_config = wal_meta;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -17,16 +17,17 @@ use std::sync::Arc;
|
||||
use cmd::options::MixOptions;
|
||||
use common_base::Plugins;
|
||||
use common_catalog::consts::MIN_USER_TABLE_ID;
|
||||
use common_config::{KvBackendConfig, WalConfig};
|
||||
use common_config::KvBackendConfig;
|
||||
use common_meta::cache_invalidator::DummyCacheInvalidator;
|
||||
use common_meta::ddl::table_meta::TableMetadataAllocator;
|
||||
use common_meta::ddl_manager::DdlManager;
|
||||
use common_meta::key::TableMetadataManager;
|
||||
use common_meta::region_keeper::MemoryRegionKeeper;
|
||||
use common_meta::sequence::SequenceBuilder;
|
||||
use common_meta::wal::{WalConfig as MetaWalConfig, WalOptionsAllocator};
|
||||
use common_meta::wal_options_allocator::WalOptionsAllocator;
|
||||
use common_procedure::options::ProcedureConfig;
|
||||
use common_telemetry::logging::LoggingOptions;
|
||||
use common_wal::config::{DatanodeWalConfig, MetaSrvWalConfig};
|
||||
use datanode::config::DatanodeOptions;
|
||||
use datanode::datanode::DatanodeBuilder;
|
||||
use frontend::frontend::FrontendOptions;
|
||||
@@ -46,8 +47,8 @@ pub struct GreptimeDbStandalone {
|
||||
#[derive(Clone)]
|
||||
pub struct GreptimeDbStandaloneBuilder {
|
||||
instance_name: String,
|
||||
wal_config: WalConfig,
|
||||
meta_wal_config: MetaWalConfig,
|
||||
wal_config: DatanodeWalConfig,
|
||||
meta_wal_config: MetaSrvWalConfig,
|
||||
store_providers: Option<Vec<StorageType>>,
|
||||
default_store: Option<StorageType>,
|
||||
plugin: Option<Plugins>,
|
||||
@@ -60,8 +61,8 @@ impl GreptimeDbStandaloneBuilder {
|
||||
store_providers: None,
|
||||
plugin: None,
|
||||
default_store: None,
|
||||
wal_config: WalConfig::default(),
|
||||
meta_wal_config: MetaWalConfig::default(),
|
||||
wal_config: DatanodeWalConfig::default(),
|
||||
meta_wal_config: MetaSrvWalConfig::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,13 +93,13 @@ impl GreptimeDbStandaloneBuilder {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_wal_config(mut self, wal_config: WalConfig) -> Self {
|
||||
pub fn with_wal_config(mut self, wal_config: DatanodeWalConfig) -> Self {
|
||||
self.wal_config = wal_config;
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_meta_wal_config(mut self, wal_meta: MetaWalConfig) -> Self {
|
||||
pub fn with_meta_wal_config(mut self, wal_meta: MetaSrvWalConfig) -> Self {
|
||||
self.meta_wal_config = wal_meta;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ use std::time::Duration;
|
||||
use auth::UserProviderRef;
|
||||
use axum::Router;
|
||||
use catalog::kvbackend::KvBackendCatalogManager;
|
||||
use common_config::WalConfig;
|
||||
use common_meta::key::catalog_name::CatalogNameKey;
|
||||
use common_meta::key::schema_name::SchemaNameKey;
|
||||
use common_runtime::Builder as RuntimeBuilder;
|
||||
use common_telemetry::warn;
|
||||
use common_test_util::ports;
|
||||
use common_test_util::temp_dir::{create_temp_dir, TempDir};
|
||||
use common_wal::config::DatanodeWalConfig;
|
||||
use datanode::config::{
|
||||
AzblobConfig, DatanodeOptions, FileConfig, GcsConfig, ObjectStoreConfig, OssConfig, S3Config,
|
||||
StorageConfig,
|
||||
@@ -302,7 +302,7 @@ pub fn create_tmp_dir_and_datanode_opts(
|
||||
default_store_type: StorageType,
|
||||
store_provider_types: Vec<StorageType>,
|
||||
name: &str,
|
||||
wal_config: WalConfig,
|
||||
wal_config: DatanodeWalConfig,
|
||||
) -> (DatanodeOptions, TestGuard) {
|
||||
let home_tmp_dir = create_temp_dir(&format!("gt_data_{name}"));
|
||||
let home_dir = home_tmp_dir.path().to_str().unwrap().to_string();
|
||||
@@ -336,7 +336,7 @@ pub(crate) fn create_datanode_opts(
|
||||
default_store: ObjectStoreConfig,
|
||||
providers: Vec<ObjectStoreConfig>,
|
||||
home_dir: String,
|
||||
wal_config: WalConfig,
|
||||
wal_config: DatanodeWalConfig,
|
||||
) -> DatanodeOptions {
|
||||
DatanodeOptions {
|
||||
node_id: Some(0),
|
||||
|
||||
@@ -15,14 +15,12 @@
|
||||
use std::env;
|
||||
use std::sync::Arc;
|
||||
|
||||
use common_config::wal::KafkaConfig;
|
||||
use common_config::WalConfig;
|
||||
use common_meta::wal::kafka::KafkaConfig as MetaKafkaConfig;
|
||||
use common_meta::wal::WalConfig as MetaWalConfig;
|
||||
use common_query::Output;
|
||||
use common_recordbatch::util;
|
||||
use common_telemetry::warn;
|
||||
use common_test_util::find_workspace_path;
|
||||
use common_wal::config::kafka::{DatanodeKafkaConfig, MetaSrvKafkaConfig};
|
||||
use common_wal::config::{DatanodeWalConfig, MetaSrvWalConfig};
|
||||
use frontend::instance::Instance;
|
||||
use rstest_reuse::{self, template};
|
||||
|
||||
@@ -163,11 +161,11 @@ pub(crate) async fn standalone_with_kafka_wal() -> Option<Box<dyn RebuildableMoc
|
||||
.collect::<Vec<_>>();
|
||||
let test_name = uuid::Uuid::new_v4().to_string();
|
||||
let builder = GreptimeDbStandaloneBuilder::new(&test_name)
|
||||
.with_wal_config(WalConfig::Kafka(KafkaConfig {
|
||||
.with_wal_config(DatanodeWalConfig::Kafka(DatanodeKafkaConfig {
|
||||
broker_endpoints: endpoints.clone(),
|
||||
..Default::default()
|
||||
}))
|
||||
.with_meta_wal_config(MetaWalConfig::Kafka(MetaKafkaConfig {
|
||||
.with_meta_wal_config(MetaSrvWalConfig::Kafka(MetaSrvKafkaConfig {
|
||||
broker_endpoints: endpoints,
|
||||
topic_name_prefix: test_name.to_string(),
|
||||
num_topics: 3,
|
||||
@@ -193,11 +191,11 @@ pub(crate) async fn distributed_with_kafka_wal() -> Option<Box<dyn RebuildableMo
|
||||
let test_name = uuid::Uuid::new_v4().to_string();
|
||||
let builder = GreptimeDbClusterBuilder::new(&test_name)
|
||||
.await
|
||||
.with_wal_config(WalConfig::Kafka(KafkaConfig {
|
||||
.with_wal_config(DatanodeWalConfig::Kafka(DatanodeKafkaConfig {
|
||||
broker_endpoints: endpoints.clone(),
|
||||
..Default::default()
|
||||
}))
|
||||
.with_meta_wal_config(MetaWalConfig::Kafka(MetaKafkaConfig {
|
||||
.with_meta_wal_config(MetaSrvWalConfig::Kafka(MetaSrvKafkaConfig {
|
||||
broker_endpoints: endpoints,
|
||||
topic_name_prefix: test_name.to_string(),
|
||||
num_topics: 3,
|
||||
|
||||
@@ -16,16 +16,14 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use client::{DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME};
|
||||
use common_config::wal::KafkaConfig;
|
||||
use common_config::WalConfig;
|
||||
use common_meta::key::{RegionDistribution, TableMetadataManagerRef};
|
||||
use common_meta::peer::Peer;
|
||||
use common_meta::wal::kafka::KafkaConfig as MetaKafkaConfig;
|
||||
use common_meta::wal::WalConfig as MetaWalConfig;
|
||||
use common_query::Output;
|
||||
use common_telemetry::info;
|
||||
use common_test_util::recordbatch::check_output_stream;
|
||||
use common_test_util::temp_dir::create_temp_dir;
|
||||
use common_wal::config::kafka::{DatanodeKafkaConfig, MetaSrvKafkaConfig};
|
||||
use common_wal::config::{DatanodeWalConfig, MetaSrvWalConfig};
|
||||
use frontend::error::Result as FrontendResult;
|
||||
use frontend::instance::Instance;
|
||||
use futures::future::BoxFuture;
|
||||
@@ -108,12 +106,12 @@ pub async fn test_region_migration(store_type: StorageType, endpoints: Vec<Strin
|
||||
let cluster = builder
|
||||
.with_datanodes(datanodes as u32)
|
||||
.with_store_config(store_config)
|
||||
.with_wal_config(WalConfig::Kafka(KafkaConfig {
|
||||
.with_wal_config(DatanodeWalConfig::Kafka(DatanodeKafkaConfig {
|
||||
broker_endpoints: endpoints.clone(),
|
||||
linger: Duration::from_millis(25),
|
||||
..Default::default()
|
||||
}))
|
||||
.with_meta_wal_config(MetaWalConfig::Kafka(MetaKafkaConfig {
|
||||
.with_meta_wal_config(MetaSrvWalConfig::Kafka(MetaSrvKafkaConfig {
|
||||
broker_endpoints: endpoints,
|
||||
num_topics: 3,
|
||||
topic_name_prefix: Uuid::new_v4().to_string(),
|
||||
@@ -238,12 +236,12 @@ pub async fn test_region_migration_multiple_regions(
|
||||
let cluster = builder
|
||||
.with_datanodes(datanodes as u32)
|
||||
.with_store_config(store_config)
|
||||
.with_wal_config(WalConfig::Kafka(KafkaConfig {
|
||||
.with_wal_config(DatanodeWalConfig::Kafka(DatanodeKafkaConfig {
|
||||
broker_endpoints: endpoints.clone(),
|
||||
linger: Duration::from_millis(25),
|
||||
..Default::default()
|
||||
}))
|
||||
.with_meta_wal_config(MetaWalConfig::Kafka(MetaKafkaConfig {
|
||||
.with_meta_wal_config(MetaSrvWalConfig::Kafka(MetaSrvKafkaConfig {
|
||||
broker_endpoints: endpoints,
|
||||
num_topics: 3,
|
||||
topic_name_prefix: Uuid::new_v4().to_string(),
|
||||
@@ -375,12 +373,12 @@ pub async fn test_region_migration_all_regions(store_type: StorageType, endpoint
|
||||
let cluster = builder
|
||||
.with_datanodes(datanodes as u32)
|
||||
.with_store_config(store_config)
|
||||
.with_wal_config(WalConfig::Kafka(KafkaConfig {
|
||||
.with_wal_config(DatanodeWalConfig::Kafka(DatanodeKafkaConfig {
|
||||
broker_endpoints: endpoints.clone(),
|
||||
linger: Duration::from_millis(25),
|
||||
..Default::default()
|
||||
}))
|
||||
.with_meta_wal_config(MetaWalConfig::Kafka(MetaKafkaConfig {
|
||||
.with_meta_wal_config(MetaSrvWalConfig::Kafka(MetaSrvKafkaConfig {
|
||||
broker_endpoints: endpoints,
|
||||
num_topics: 3,
|
||||
topic_name_prefix: Uuid::new_v4().to_string(),
|
||||
@@ -507,12 +505,12 @@ pub async fn test_region_migration_incorrect_from_peer(
|
||||
let cluster = builder
|
||||
.with_datanodes(datanodes as u32)
|
||||
.with_store_config(store_config)
|
||||
.with_wal_config(WalConfig::Kafka(KafkaConfig {
|
||||
.with_wal_config(DatanodeWalConfig::Kafka(DatanodeKafkaConfig {
|
||||
broker_endpoints: endpoints.clone(),
|
||||
linger: Duration::from_millis(25),
|
||||
..Default::default()
|
||||
}))
|
||||
.with_meta_wal_config(MetaWalConfig::Kafka(MetaKafkaConfig {
|
||||
.with_meta_wal_config(MetaSrvWalConfig::Kafka(MetaSrvKafkaConfig {
|
||||
broker_endpoints: endpoints,
|
||||
num_topics: 3,
|
||||
topic_name_prefix: Uuid::new_v4().to_string(),
|
||||
@@ -582,12 +580,12 @@ pub async fn test_region_migration_incorrect_region_id(
|
||||
let cluster = builder
|
||||
.with_datanodes(datanodes as u32)
|
||||
.with_store_config(store_config)
|
||||
.with_wal_config(WalConfig::Kafka(KafkaConfig {
|
||||
.with_wal_config(DatanodeWalConfig::Kafka(DatanodeKafkaConfig {
|
||||
broker_endpoints: endpoints.clone(),
|
||||
linger: Duration::from_millis(25),
|
||||
..Default::default()
|
||||
}))
|
||||
.with_meta_wal_config(MetaWalConfig::Kafka(MetaKafkaConfig {
|
||||
.with_meta_wal_config(MetaSrvWalConfig::Kafka(MetaSrvKafkaConfig {
|
||||
broker_endpoints: endpoints,
|
||||
num_topics: 3,
|
||||
topic_name_prefix: Uuid::new_v4().to_string(),
|
||||
|
||||
Reference in New Issue
Block a user