From 92e571d853bb0421abe67e11859eebc7d32c12c7 Mon Sep 17 00:00:00 2001 From: zyy17 Date: Thu, 2 Oct 2025 23:21:21 +0800 Subject: [PATCH 1/5] refactor: add `hostname` in cluster_info table Signed-off-by: zyy17 --- Cargo.lock | 7 ++- Cargo.toml | 3 +- .../information_schema/cluster_info.rs | 8 ++++ src/common/meta/src/cluster.rs | 3 ++ src/datanode/Cargo.toml | 1 + src/datanode/src/heartbeat.rs | 4 ++ src/flow/Cargo.toml | 1 + src/flow/src/heartbeat.rs | 4 ++ src/frontend/Cargo.toml | 1 + src/frontend/src/heartbeat.rs | 4 ++ src/meta-client/src/client.rs | 44 +++++++++++-------- src/meta-srv/Cargo.toml | 1 + src/meta-srv/src/discovery/lease.rs | 3 ++ src/meta-srv/src/election/rds/mysql.rs | 1 + src/meta-srv/src/election/rds/postgres.rs | 1 + .../handler/collect_cluster_info_handler.rs | 3 ++ src/meta-srv/src/metasrv.rs | 19 +++++--- src/meta-srv/src/service/cluster.rs | 4 ++ src/standalone/Cargo.toml | 1 + src/standalone/src/information_extension.rs | 4 ++ src/store-api/src/region_request.rs | 25 +++++------ 21 files changed, 104 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 929bb77b2334..d5f18867da36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3929,6 +3929,7 @@ dependencies = [ "file-engine", "futures", "futures-util", + "hostname 0.4.1", "humantime-serde", "lazy_static", "log-store", @@ -4804,6 +4805,7 @@ dependencies = [ "futures", "get-size2", "greptime-proto", + "hostname 0.4.1", "http 1.3.1", "humantime-serde", "itertools 0.14.0", @@ -4920,6 +4922,7 @@ dependencies = [ "datanode", "datatypes", "futures", + "hostname 0.4.1", "humantime", "humantime-serde", "lazy_static", @@ -5325,7 +5328,7 @@ dependencies = [ [[package]] name = "greptime-proto" version = "0.1.0" -source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=d75496d5d09dedcd0edcade57ccf0a522f4393ae#d75496d5d09dedcd0edcade57ccf0a522f4393ae" +source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=1e291dda3b94ae3d6cfde32dd8f6be71154c13cd#1e291dda3b94ae3d6cfde32dd8f6be71154c13cd" dependencies = [ "prost 0.13.5", "prost-types 0.13.5", @@ -7412,6 +7415,7 @@ dependencies = [ "etcd-client", "futures", "h2 0.3.26", + "hostname 0.4.1", "http-body-util", "humantime", "humantime-serde", @@ -12363,6 +12367,7 @@ dependencies = [ "file-engine", "flow", "frontend", + "hostname 0.4.1", "log-store", "mito2", "query", diff --git a/Cargo.toml b/Cargo.toml index 1185c9b2d573..f8eb0f14dbc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -147,7 +147,7 @@ etcd-client = { git = "https://github.com/GreptimeTeam/etcd-client", rev = "f62d fst = "0.4.7" futures = "0.3" futures-util = "0.3" -greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "d75496d5d09dedcd0edcade57ccf0a522f4393ae" } +greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "1e291dda3b94ae3d6cfde32dd8f6be71154c13cd" } hex = "0.4" http = "1" humantime = "2.1" @@ -207,6 +207,7 @@ rstest_reuse = "0.7" rust_decimal = "1.33" rustc-hash = "2.0" # It is worth noting that we should try to avoid using aws-lc-rs until it can be compiled on various platforms. +hostname = "0.4.0" rustls = { version = "0.23.25", default-features = false } sea-query = "0.32" serde = { version = "1.0", features = ["derive"] } diff --git a/src/catalog/src/system_schema/information_schema/cluster_info.rs b/src/catalog/src/system_schema/information_schema/cluster_info.rs index 4082629bd45f..bd4186e620b3 100644 --- a/src/catalog/src/system_schema/information_schema/cluster_info.rs +++ b/src/catalog/src/system_schema/information_schema/cluster_info.rs @@ -58,6 +58,7 @@ const START_TIME: &str = "start_time"; const UPTIME: &str = "uptime"; const ACTIVE_TIME: &str = "active_time"; const NODE_STATUS: &str = "node_status"; +const HOSTNAME: &str = "hostname"; const INIT_CAPACITY: usize = 42; @@ -74,6 +75,7 @@ const INIT_CAPACITY: usize = 42; /// - `uptime`: the uptime of the peer. /// - `active_time`: the time since the last activity of the peer. /// - `node_status`: the status info of the peer. +/// - `hostname`: the hostname of the peer. /// #[derive(Debug)] pub(super) struct InformationSchemaClusterInfo { @@ -106,6 +108,7 @@ impl InformationSchemaClusterInfo { ColumnSchema::new(UPTIME, ConcreteDataType::string_datatype(), true), ColumnSchema::new(ACTIVE_TIME, ConcreteDataType::string_datatype(), true), ColumnSchema::new(NODE_STATUS, ConcreteDataType::string_datatype(), true), + ColumnSchema::new(HOSTNAME, ConcreteDataType::string_datatype(), true), ])) } @@ -163,6 +166,7 @@ struct InformationSchemaClusterInfoBuilder { uptimes: StringVectorBuilder, active_times: StringVectorBuilder, node_status: StringVectorBuilder, + hostnames: StringVectorBuilder, } impl InformationSchemaClusterInfoBuilder { @@ -181,6 +185,7 @@ impl InformationSchemaClusterInfoBuilder { uptimes: StringVectorBuilder::with_capacity(INIT_CAPACITY), active_times: StringVectorBuilder::with_capacity(INIT_CAPACITY), node_status: StringVectorBuilder::with_capacity(INIT_CAPACITY), + hostnames: StringVectorBuilder::with_capacity(INIT_CAPACITY), } } @@ -205,6 +210,7 @@ impl InformationSchemaClusterInfoBuilder { (PEER_ADDR, &Value::from(node_info.peer.addr.as_str())), (VERSION, &Value::from(node_info.version.as_str())), (GIT_COMMIT, &Value::from(node_info.git_commit.as_str())), + (HOSTNAME, &Value::from(node_info.hostname.as_str())), ]; if !predicates.eval(&row) { @@ -230,6 +236,7 @@ impl InformationSchemaClusterInfoBuilder { } self.cpus.push(Some(node_info.cpus)); self.memory_bytes.push(Some(node_info.memory_bytes)); + self.hostnames.push(Some(&node_info.hostname)); if node_info.last_activity_ts > 0 { self.active_times.push(Some( @@ -261,6 +268,7 @@ impl InformationSchemaClusterInfoBuilder { Arc::new(self.uptimes.finish()), Arc::new(self.active_times.finish()), Arc::new(self.node_status.finish()), + Arc::new(self.hostnames.finish()), ]; RecordBatch::new(self.schema.clone(), columns).context(CreateRecordBatchSnafu) } diff --git a/src/common/meta/src/cluster.rs b/src/common/meta/src/cluster.rs index c7820477b7bb..7addae6bd6a8 100644 --- a/src/common/meta/src/cluster.rs +++ b/src/common/meta/src/cluster.rs @@ -124,6 +124,8 @@ pub struct NodeInfo { // The node build memory bytes #[serde(default)] pub memory_bytes: u64, + // The node build hostname + pub hostname: String, } #[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, Serialize, Deserialize)] @@ -332,6 +334,7 @@ mod tests { start_time_ms: 1, cpus: 0, memory_bytes: 0, + hostname: "test_hostname".to_string(), }; let node_info_bytes: Vec = node_info.try_into().unwrap(); diff --git a/src/datanode/Cargo.toml b/src/datanode/Cargo.toml index 0abbefa76e37..b9728af50bd6 100644 --- a/src/datanode/Cargo.toml +++ b/src/datanode/Cargo.toml @@ -43,6 +43,7 @@ datatypes.workspace = true file-engine.workspace = true futures.workspace = true futures-util.workspace = true +hostname.workspace = true humantime-serde.workspace = true lazy_static.workspace = true log-store.workspace = true diff --git a/src/datanode/src/heartbeat.rs b/src/datanode/src/heartbeat.rs index 5b8fa4c1e31c..bb3f25957c2a 100644 --- a/src/datanode/src/heartbeat.rs +++ b/src/datanode/src/heartbeat.rs @@ -251,6 +251,10 @@ impl HeartbeatTask { start_time_ms: node_epoch, cpus, memory_bytes, + hostname: hostname::get() + .unwrap_or_default() + .to_string_lossy() + .to_string(), }), node_workloads: Some(NodeWorkloads::Datanode(DatanodeWorkloads { types: workload_types.iter().map(|w| w.to_i32()).collect(), diff --git a/src/flow/Cargo.toml b/src/flow/Cargo.toml index 9e0204d91736..7da961084434 100644 --- a/src/flow/Cargo.toml +++ b/src/flow/Cargo.toml @@ -48,6 +48,7 @@ enum_dispatch = "0.3" futures.workspace = true get-size2 = "0.1.2" greptime-proto.workspace = true +hostname.workspace = true http.workspace = true humantime-serde.workspace = true itertools.workspace = true diff --git a/src/flow/src/heartbeat.rs b/src/flow/src/heartbeat.rs index 62db52444f48..cc42668f5a00 100644 --- a/src/flow/src/heartbeat.rs +++ b/src/flow/src/heartbeat.rs @@ -185,6 +185,10 @@ impl HeartbeatTask { start_time_ms, cpus, memory_bytes, + hostname: hostname::get() + .unwrap_or_default() + .to_string_lossy() + .to_string(), }) } diff --git a/src/frontend/Cargo.toml b/src/frontend/Cargo.toml index bf6b6bd25d92..db26316c39f5 100644 --- a/src/frontend/Cargo.toml +++ b/src/frontend/Cargo.toml @@ -46,6 +46,7 @@ datafusion-expr.workspace = true datanode.workspace = true datatypes.workspace = true futures.workspace = true +hostname.workspace = true humantime.workspace = true humantime-serde.workspace = true lazy_static.workspace = true diff --git a/src/frontend/src/heartbeat.rs b/src/frontend/src/heartbeat.rs index 59514f7da48b..76fdc3305bdf 100644 --- a/src/frontend/src/heartbeat.rs +++ b/src/frontend/src/heartbeat.rs @@ -158,6 +158,10 @@ impl HeartbeatTask { start_time_ms, cpus, memory_bytes, + hostname: hostname::get() + .unwrap_or_default() + .to_string_lossy() + .to_string(), }) } diff --git a/src/meta-client/src/client.rs b/src/meta-client/src/client.rs index 9091156f5ca7..b64b648219fc 100644 --- a/src/meta-client/src/client.rs +++ b/src/meta-client/src/client.rs @@ -372,25 +372,33 @@ impl ClusterInfo for MetaClient { let (leader, followers) = cluster_client.get_metasrv_peers().await?; followers .into_iter() - .map(|node| NodeInfo { - peer: node.peer.unwrap_or_default(), - last_activity_ts, - status: NodeStatus::Metasrv(MetasrvStatus { is_leader: false }), - version: node.version, - git_commit: node.git_commit, - start_time_ms: node.start_time_ms, - cpus: node.cpus, - memory_bytes: node.memory_bytes, + .map(|node| { + let node_info = node.info.unwrap_or_default(); + NodeInfo { + peer: node.peer.unwrap_or_default(), + last_activity_ts, + status: NodeStatus::Metasrv(MetasrvStatus { is_leader: false }), + version: node_info.version, + git_commit: node_info.git_commit, + start_time_ms: node_info.start_time_ms, + cpus: node_info.cpus, + memory_bytes: node_info.memory_bytes, + hostname: node_info.hostname, + } }) - .chain(leader.into_iter().map(|node| NodeInfo { - peer: node.peer.unwrap_or_default(), - last_activity_ts, - status: NodeStatus::Metasrv(MetasrvStatus { is_leader: true }), - version: node.version, - git_commit: node.git_commit, - start_time_ms: node.start_time_ms, - cpus: node.cpus, - memory_bytes: node.memory_bytes, + .chain(leader.into_iter().map(|node| { + let node_info = node.info.unwrap_or_default(); + NodeInfo { + peer: node.peer.unwrap_or_default(), + last_activity_ts, + status: NodeStatus::Metasrv(MetasrvStatus { is_leader: true }), + version: node_info.version, + git_commit: node_info.git_commit, + start_time_ms: node_info.start_time_ms, + cpus: node_info.cpus, + memory_bytes: node_info.memory_bytes, + hostname: node_info.hostname, + } })) .collect::>() } else { diff --git a/src/meta-srv/Cargo.toml b/src/meta-srv/Cargo.toml index b521ddad6cff..90a4fdc17b80 100644 --- a/src/meta-srv/Cargo.toml +++ b/src/meta-srv/Cargo.toml @@ -53,6 +53,7 @@ either.workspace = true etcd-client.workspace = true futures.workspace = true h2 = "0.3" +hostname.workspace = true http-body-util = "0.1" humantime.workspace = true humantime-serde.workspace = true diff --git a/src/meta-srv/src/discovery/lease.rs b/src/meta-srv/src/discovery/lease.rs index 557437964e54..46b92c0f1ae6 100644 --- a/src/meta-srv/src/discovery/lease.rs +++ b/src/meta-srv/src/discovery/lease.rs @@ -245,6 +245,7 @@ mod tests { start_time_ms: current_time_millis() as u64, cpus: 0, memory_bytes: 0, + hostname: "test_hostname".to_string(), }; let key_prefix = NodeInfoKey::key_prefix_with_role(Role::Frontend); @@ -270,6 +271,7 @@ mod tests { start_time_ms: current_time_millis() as u64, cpus: 0, memory_bytes: 0, + hostname: "test_hostname".to_string(), }; in_memory @@ -307,6 +309,7 @@ mod tests { start_time_ms: last_activity_ts as u64, cpus: 0, memory_bytes: 0, + hostname: "test_hostname".to_string(), }; let key_prefix = NodeInfoKey::key_prefix_with_role(Role::Frontend); diff --git a/src/meta-srv/src/election/rds/mysql.rs b/src/meta-srv/src/election/rds/mysql.rs index 6737f40054ce..a0890969f86c 100644 --- a/src/meta-srv/src/election/rds/mysql.rs +++ b/src/meta-srv/src/election/rds/mysql.rs @@ -1163,6 +1163,7 @@ mod tests { start_time_ms: 0, cpus: 0, memory_bytes: 0, + hostname: "test_hostname".to_string(), }; mysql_election.register_candidate(&node_info).await.unwrap(); } diff --git a/src/meta-srv/src/election/rds/postgres.rs b/src/meta-srv/src/election/rds/postgres.rs index f577cc111ab0..14b2bbb40986 100644 --- a/src/meta-srv/src/election/rds/postgres.rs +++ b/src/meta-srv/src/election/rds/postgres.rs @@ -1002,6 +1002,7 @@ mod tests { start_time_ms: 0, cpus: 0, memory_bytes: 0, + hostname: "test_hostname".to_string(), }; pg_election.register_candidate(&node_info).await.unwrap(); } diff --git a/src/meta-srv/src/handler/collect_cluster_info_handler.rs b/src/meta-srv/src/handler/collect_cluster_info_handler.rs index 8ce24e86368a..f144f3edc5dc 100644 --- a/src/meta-srv/src/handler/collect_cluster_info_handler.rs +++ b/src/meta-srv/src/handler/collect_cluster_info_handler.rs @@ -54,6 +54,7 @@ impl HeartbeatHandler for CollectFrontendClusterInfoHandler { start_time_ms: info.start_time_ms, cpus: info.cpus, memory_bytes: info.memory_bytes, + hostname: info.hostname, }; put_into_memory_store(ctx, key, value).await?; @@ -89,6 +90,7 @@ impl HeartbeatHandler for CollectFlownodeClusterInfoHandler { start_time_ms: info.start_time_ms, cpus: info.cpus, memory_bytes: info.memory_bytes, + hostname: info.hostname, }; put_into_memory_store(ctx, key, value).await?; @@ -142,6 +144,7 @@ impl HeartbeatHandler for CollectDatanodeClusterInfoHandler { start_time_ms: info.start_time_ms, cpus: info.cpus, memory_bytes: info.memory_bytes, + hostname: info.hostname, }; put_into_memory_store(ctx, key, value).await?; diff --git a/src/meta-srv/src/metasrv.rs b/src/meta-srv/src/metasrv.rs index 615e75d3178d..f8260d087306 100644 --- a/src/meta-srv/src/metasrv.rs +++ b/src/meta-srv/src/metasrv.rs @@ -378,6 +378,8 @@ pub struct MetasrvNodeInfo { #[serde(default)] // The node memory bytes pub memory_bytes: u64, + // The node hostname + pub hostname: String, } impl From for api::v1::meta::MetasrvNodeInfo { @@ -387,11 +389,14 @@ impl From for api::v1::meta::MetasrvNodeInfo { addr: node_info.addr, ..Default::default() }), - version: node_info.version, - git_commit: node_info.git_commit, - start_time_ms: node_info.start_time_ms, - cpus: node_info.cpus, - memory_bytes: node_info.memory_bytes, + info: Some(api::v1::meta::NodeInfo { + version: node_info.version, + git_commit: node_info.git_commit, + start_time_ms: node_info.start_time_ms, + cpus: node_info.cpus, + memory_bytes: node_info.memory_bytes, + hostname: node_info.hostname, + }), } } } @@ -696,6 +701,10 @@ impl Metasrv { start_time_ms: self.start_time_ms(), cpus: self.resource_spec().cpus as u32, memory_bytes: self.resource_spec().memory.unwrap_or_default().as_bytes(), + hostname: hostname::get() + .unwrap_or_default() + .to_string_lossy() + .to_string(), } } diff --git a/src/meta-srv/src/service/cluster.rs b/src/meta-srv/src/service/cluster.rs index 392268ff6d35..e39337c37466 100644 --- a/src/meta-srv/src/service/cluster.rs +++ b/src/meta-srv/src/service/cluster.rs @@ -99,6 +99,10 @@ impl Metasrv { start_time_ms: self.start_time_ms(), cpus: self.resource_spec().cpus as u32, memory_bytes: self.resource_spec().memory.unwrap_or_default().as_bytes(), + hostname: hostname::get() + .unwrap_or_default() + .to_string_lossy() + .to_string(), } .into() } diff --git a/src/standalone/Cargo.toml b/src/standalone/Cargo.toml index 035b1dc06a54..bc97b707c245 100644 --- a/src/standalone/Cargo.toml +++ b/src/standalone/Cargo.toml @@ -27,6 +27,7 @@ datanode.workspace = true file-engine.workspace = true flow.workspace = true frontend.workspace = true +hostname.workspace = true log-store.workspace = true mito2.workspace = true query.workspace = true diff --git a/src/standalone/src/information_extension.rs b/src/standalone/src/information_extension.rs index 347955cfab85..83441460fb1e 100644 --- a/src/standalone/src/information_extension.rs +++ b/src/standalone/src/information_extension.rs @@ -79,6 +79,10 @@ impl InformationExtension for StandaloneInformationExtension { memory_bytes: common_config::utils::get_sys_total_memory() .unwrap_or_default() .as_bytes(), + hostname: hostname::get() + .unwrap_or_default() + .to_string_lossy() + .to_string(), }; Ok(vec![node_info]) } diff --git a/src/store-api/src/region_request.rs b/src/store-api/src/region_request.rs index 009cb4eeaff0..51ab1756d363 100644 --- a/src/store-api/src/region_request.rs +++ b/src/store-api/src/region_request.rs @@ -15,16 +15,16 @@ use std::collections::HashMap; use std::fmt::{self, Display}; -use api::helper::{ColumnDataTypeWrapper, from_pb_time_ranges}; +use api::helper::{from_pb_time_ranges, ColumnDataTypeWrapper}; use api::v1::add_column_location::LocationType; use api::v1::column_def::{ as_fulltext_option_analyzer, as_fulltext_option_backend, as_skipping_index_type, }; use api::v1::region::bulk_insert_request::Body; use api::v1::region::{ - AlterRequest, AlterRequests, BulkInsertRequest, CloseRequest, CompactRequest, CreateRequest, - CreateRequests, DeleteRequests, DropRequest, DropRequests, FlushRequest, InsertRequests, - OpenRequest, TruncateRequest, alter_request, compact_request, region_request, truncate_request, + alter_request, compact_request, region_request, truncate_request, AlterRequest, AlterRequests, + BulkInsertRequest, CloseRequest, CompactRequest, CreateRequest, CreateRequests, DeleteRequests, + DropRequest, DropRequests, FlushRequest, InsertRequests, OpenRequest, TruncateRequest, }; use api::v1::{ self, Analyzer, ArrowIpc, FulltextBackend as PbFulltextBackend, Option as PbOption, Rows, @@ -38,7 +38,7 @@ use datatypes::prelude::ConcreteDataType; use datatypes::schema::{FulltextOptions, SkippingIndexOptions}; use num_enum::TryFromPrimitive; use serde::{Deserialize, Serialize}; -use snafu::{OptionExt, ResultExt, ensure}; +use snafu::{ensure, OptionExt, ResultExt}; use strum::{AsRefStr, IntoStaticStr}; use crate::logstore::entry; @@ -178,6 +178,7 @@ impl RegionRequest { reason: "ListMetadata request should be handled separately by RegionServer", } .fail(), + region_request::Body::BuildIndex(_) => todo!(), } } @@ -1942,10 +1943,9 @@ mod tests { column_metadatas: column_metadatas_with_different_ts_column, }; let err = kind.validate(&metadata).unwrap_err(); - assert!( - err.to_string() - .contains("timestamp column ts has different id") - ); + assert!(err + .to_string() + .contains("timestamp column ts has different id")); // Change the primary key column name. let mut column_metadatas_with_different_pk_column = metadata.column_metadatas.clone(); @@ -1958,10 +1958,9 @@ mod tests { column_metadatas: column_metadatas_with_different_pk_column, }; let err = kind.validate(&metadata).unwrap_err(); - assert!( - err.to_string() - .contains("column with same name tag_0 has different id") - ); + assert!(err + .to_string() + .contains("column with same name tag_0 has different id")); // Add a new field column. let mut column_metadatas_with_new_field_column = metadata.column_metadatas.clone(); From bcef0cdfb4ea0e7870a12cf678346147afb2997b Mon Sep 17 00:00:00 2001 From: zyy17 Date: Fri, 3 Oct 2025 11:16:12 +0800 Subject: [PATCH 2/5] chore: update information schema result Signed-off-by: zyy17 --- tests/cases/distributed/information_schema/cluster_info.result | 1 + tests/cases/standalone/common/system/information_schema.result | 1 + tests/cases/standalone/information_schema/cluster_info.result | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/cases/distributed/information_schema/cluster_info.result b/tests/cases/distributed/information_schema/cluster_info.result index 76875e564102..152c835eaaa5 100644 --- a/tests/cases/distributed/information_schema/cluster_info.result +++ b/tests/cases/distributed/information_schema/cluster_info.result @@ -18,6 +18,7 @@ DESC TABLE CLUSTER_INFO; | uptime | String | | YES | | FIELD | | active_time | String | | YES | | FIELD | | node_status | String | | YES | | FIELD | +| hostname | String | | YES | | FIELD | +--------------+----------------------+-----+------+---------+---------------+ -- SQLNESS REPLACE version node_version diff --git a/tests/cases/standalone/common/system/information_schema.result b/tests/cases/standalone/common/system/information_schema.result index 8d24c33b77bc..b38b104d8236 100644 --- a/tests/cases/standalone/common/system/information_schema.result +++ b/tests/cases/standalone/common/system/information_schema.result @@ -74,6 +74,7 @@ select * from information_schema.columns order by table_schema, table_name, colu | greptime | information_schema | cluster_info | active_time | 10 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | | greptime | information_schema | cluster_info | cpus | 4 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | No | int unsigned | | | | greptime | information_schema | cluster_info | git_commit | 7 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | cluster_info | hostname | 12 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | | greptime | information_schema | cluster_info | memory_bytes | 5 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | No | bigint unsigned | | | | greptime | information_schema | cluster_info | node_status | 11 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | | greptime | information_schema | cluster_info | peer_addr | 3 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | diff --git a/tests/cases/standalone/information_schema/cluster_info.result b/tests/cases/standalone/information_schema/cluster_info.result index 674d687cac79..6c0ab9a49b2f 100644 --- a/tests/cases/standalone/information_schema/cluster_info.result +++ b/tests/cases/standalone/information_schema/cluster_info.result @@ -18,6 +18,7 @@ DESC TABLE CLUSTER_INFO; | uptime | String | | YES | | FIELD | | active_time | String | | YES | | FIELD | | node_status | String | | YES | | FIELD | +| hostname | String | | YES | | FIELD | +--------------+----------------------+-----+------+---------+---------------+ -- SQLNESS REPLACE version node_version From 5b31c171128613372037733677a4968034cced03 Mon Sep 17 00:00:00 2001 From: zyy17 Date: Wed, 15 Oct 2025 17:23:01 +0800 Subject: [PATCH 3/5] chore: apply code review comments Signed-off-by: zyy17 --- .../information_schema/cluster_info.rs | 16 +++++----- src/common/meta/src/cluster.rs | 1 + src/meta-srv/src/metasrv.rs | 3 +- src/store-api/src/region_request.rs | 24 +++++++------- .../information_schema/cluster_info.result | 32 +++++++++---------- .../common/system/information_schema.result | 18 +++++------ .../information_schema/cluster_info.result | 32 +++++++++---------- 7 files changed, 65 insertions(+), 61 deletions(-) diff --git a/src/catalog/src/system_schema/information_schema/cluster_info.rs b/src/catalog/src/system_schema/information_schema/cluster_info.rs index bd4186e620b3..861b7206dee0 100644 --- a/src/catalog/src/system_schema/information_schema/cluster_info.rs +++ b/src/catalog/src/system_schema/information_schema/cluster_info.rs @@ -50,6 +50,7 @@ const PEER_TYPE_METASRV: &str = "METASRV"; const PEER_ID: &str = "peer_id"; const PEER_TYPE: &str = "peer_type"; const PEER_ADDR: &str = "peer_addr"; +const PEER_HOSTNAME: &str = "peer_hostname"; const CPUS: &str = "cpus"; const MEMORY_BYTES: &str = "memory_bytes"; const VERSION: &str = "version"; @@ -58,7 +59,6 @@ const START_TIME: &str = "start_time"; const UPTIME: &str = "uptime"; const ACTIVE_TIME: &str = "active_time"; const NODE_STATUS: &str = "node_status"; -const HOSTNAME: &str = "hostname"; const INIT_CAPACITY: usize = 42; @@ -75,7 +75,7 @@ const INIT_CAPACITY: usize = 42; /// - `uptime`: the uptime of the peer. /// - `active_time`: the time since the last activity of the peer. /// - `node_status`: the status info of the peer. -/// - `hostname`: the hostname of the peer. +/// - `peer_hostname`: the hostname of the peer. /// #[derive(Debug)] pub(super) struct InformationSchemaClusterInfo { @@ -96,6 +96,7 @@ impl InformationSchemaClusterInfo { ColumnSchema::new(PEER_ID, ConcreteDataType::int64_datatype(), false), ColumnSchema::new(PEER_TYPE, ConcreteDataType::string_datatype(), false), ColumnSchema::new(PEER_ADDR, ConcreteDataType::string_datatype(), true), + ColumnSchema::new(PEER_HOSTNAME, ConcreteDataType::string_datatype(), true), ColumnSchema::new(CPUS, ConcreteDataType::uint32_datatype(), false), ColumnSchema::new(MEMORY_BYTES, ConcreteDataType::uint64_datatype(), false), ColumnSchema::new(VERSION, ConcreteDataType::string_datatype(), false), @@ -108,7 +109,6 @@ impl InformationSchemaClusterInfo { ColumnSchema::new(UPTIME, ConcreteDataType::string_datatype(), true), ColumnSchema::new(ACTIVE_TIME, ConcreteDataType::string_datatype(), true), ColumnSchema::new(NODE_STATUS, ConcreteDataType::string_datatype(), true), - ColumnSchema::new(HOSTNAME, ConcreteDataType::string_datatype(), true), ])) } @@ -158,6 +158,7 @@ struct InformationSchemaClusterInfoBuilder { peer_ids: Int64VectorBuilder, peer_types: StringVectorBuilder, peer_addrs: StringVectorBuilder, + peer_hostnames: StringVectorBuilder, cpus: UInt32VectorBuilder, memory_bytes: UInt64VectorBuilder, versions: StringVectorBuilder, @@ -166,7 +167,6 @@ struct InformationSchemaClusterInfoBuilder { uptimes: StringVectorBuilder, active_times: StringVectorBuilder, node_status: StringVectorBuilder, - hostnames: StringVectorBuilder, } impl InformationSchemaClusterInfoBuilder { @@ -177,6 +177,7 @@ impl InformationSchemaClusterInfoBuilder { peer_ids: Int64VectorBuilder::with_capacity(INIT_CAPACITY), peer_types: StringVectorBuilder::with_capacity(INIT_CAPACITY), peer_addrs: StringVectorBuilder::with_capacity(INIT_CAPACITY), + peer_hostnames: StringVectorBuilder::with_capacity(INIT_CAPACITY), cpus: UInt32VectorBuilder::with_capacity(INIT_CAPACITY), memory_bytes: UInt64VectorBuilder::with_capacity(INIT_CAPACITY), versions: StringVectorBuilder::with_capacity(INIT_CAPACITY), @@ -185,7 +186,6 @@ impl InformationSchemaClusterInfoBuilder { uptimes: StringVectorBuilder::with_capacity(INIT_CAPACITY), active_times: StringVectorBuilder::with_capacity(INIT_CAPACITY), node_status: StringVectorBuilder::with_capacity(INIT_CAPACITY), - hostnames: StringVectorBuilder::with_capacity(INIT_CAPACITY), } } @@ -208,9 +208,9 @@ impl InformationSchemaClusterInfoBuilder { (PEER_ID, &Value::from(peer_id)), (PEER_TYPE, &Value::from(peer_type)), (PEER_ADDR, &Value::from(node_info.peer.addr.as_str())), + (PEER_HOSTNAME, &Value::from(node_info.hostname.as_str())), (VERSION, &Value::from(node_info.version.as_str())), (GIT_COMMIT, &Value::from(node_info.git_commit.as_str())), - (HOSTNAME, &Value::from(node_info.hostname.as_str())), ]; if !predicates.eval(&row) { @@ -220,6 +220,7 @@ impl InformationSchemaClusterInfoBuilder { self.peer_ids.push(Some(peer_id)); self.peer_types.push(Some(peer_type)); self.peer_addrs.push(Some(&node_info.peer.addr)); + self.peer_hostnames.push(Some(&node_info.hostname)); self.versions.push(Some(&node_info.version)); self.git_commits.push(Some(&node_info.git_commit)); if node_info.start_time_ms > 0 { @@ -236,7 +237,6 @@ impl InformationSchemaClusterInfoBuilder { } self.cpus.push(Some(node_info.cpus)); self.memory_bytes.push(Some(node_info.memory_bytes)); - self.hostnames.push(Some(&node_info.hostname)); if node_info.last_activity_ts > 0 { self.active_times.push(Some( @@ -260,6 +260,7 @@ impl InformationSchemaClusterInfoBuilder { Arc::new(self.peer_ids.finish()), Arc::new(self.peer_types.finish()), Arc::new(self.peer_addrs.finish()), + Arc::new(self.peer_hostnames.finish()), Arc::new(self.cpus.finish()), Arc::new(self.memory_bytes.finish()), Arc::new(self.versions.finish()), @@ -268,7 +269,6 @@ impl InformationSchemaClusterInfoBuilder { Arc::new(self.uptimes.finish()), Arc::new(self.active_times.finish()), Arc::new(self.node_status.finish()), - Arc::new(self.hostnames.finish()), ]; RecordBatch::new(self.schema.clone(), columns).context(CreateRecordBatchSnafu) } diff --git a/src/common/meta/src/cluster.rs b/src/common/meta/src/cluster.rs index 7addae6bd6a8..63001970b6ae 100644 --- a/src/common/meta/src/cluster.rs +++ b/src/common/meta/src/cluster.rs @@ -125,6 +125,7 @@ pub struct NodeInfo { #[serde(default)] pub memory_bytes: u64, // The node build hostname + #[serde(default)] pub hostname: String, } diff --git a/src/meta-srv/src/metasrv.rs b/src/meta-srv/src/metasrv.rs index f8260d087306..721e21428cf3 100644 --- a/src/meta-srv/src/metasrv.rs +++ b/src/meta-srv/src/metasrv.rs @@ -375,10 +375,11 @@ pub struct MetasrvNodeInfo { // The node cpus #[serde(default)] pub cpus: u32, - #[serde(default)] // The node memory bytes + #[serde(default)] pub memory_bytes: u64, // The node hostname + #[serde(default)] pub hostname: String, } diff --git a/src/store-api/src/region_request.rs b/src/store-api/src/region_request.rs index 51ab1756d363..ef64c45a59b5 100644 --- a/src/store-api/src/region_request.rs +++ b/src/store-api/src/region_request.rs @@ -15,16 +15,16 @@ use std::collections::HashMap; use std::fmt::{self, Display}; -use api::helper::{from_pb_time_ranges, ColumnDataTypeWrapper}; +use api::helper::{ColumnDataTypeWrapper, from_pb_time_ranges}; use api::v1::add_column_location::LocationType; use api::v1::column_def::{ as_fulltext_option_analyzer, as_fulltext_option_backend, as_skipping_index_type, }; use api::v1::region::bulk_insert_request::Body; use api::v1::region::{ - alter_request, compact_request, region_request, truncate_request, AlterRequest, AlterRequests, - BulkInsertRequest, CloseRequest, CompactRequest, CreateRequest, CreateRequests, DeleteRequests, - DropRequest, DropRequests, FlushRequest, InsertRequests, OpenRequest, TruncateRequest, + AlterRequest, AlterRequests, BulkInsertRequest, CloseRequest, CompactRequest, CreateRequest, + CreateRequests, DeleteRequests, DropRequest, DropRequests, FlushRequest, InsertRequests, + OpenRequest, TruncateRequest, alter_request, compact_request, region_request, truncate_request, }; use api::v1::{ self, Analyzer, ArrowIpc, FulltextBackend as PbFulltextBackend, Option as PbOption, Rows, @@ -38,7 +38,7 @@ use datatypes::prelude::ConcreteDataType; use datatypes::schema::{FulltextOptions, SkippingIndexOptions}; use num_enum::TryFromPrimitive; use serde::{Deserialize, Serialize}; -use snafu::{ensure, OptionExt, ResultExt}; +use snafu::{OptionExt, ResultExt, ensure}; use strum::{AsRefStr, IntoStaticStr}; use crate::logstore::entry; @@ -1943,9 +1943,10 @@ mod tests { column_metadatas: column_metadatas_with_different_ts_column, }; let err = kind.validate(&metadata).unwrap_err(); - assert!(err - .to_string() - .contains("timestamp column ts has different id")); + assert!( + err.to_string() + .contains("timestamp column ts has different id") + ); // Change the primary key column name. let mut column_metadatas_with_different_pk_column = metadata.column_metadatas.clone(); @@ -1958,9 +1959,10 @@ mod tests { column_metadatas: column_metadatas_with_different_pk_column, }; let err = kind.validate(&metadata).unwrap_err(); - assert!(err - .to_string() - .contains("column with same name tag_0 has different id")); + assert!( + err.to_string() + .contains("column with same name tag_0 has different id") + ); // Add a new field column. let mut column_metadatas_with_new_field_column = metadata.column_metadatas.clone(); diff --git a/tests/cases/distributed/information_schema/cluster_info.result b/tests/cases/distributed/information_schema/cluster_info.result index 152c835eaaa5..43cb854c6dde 100644 --- a/tests/cases/distributed/information_schema/cluster_info.result +++ b/tests/cases/distributed/information_schema/cluster_info.result @@ -4,22 +4,22 @@ Affected Rows: 0 DESC TABLE CLUSTER_INFO; -+--------------+----------------------+-----+------+---------+---------------+ -| Column | Type | Key | Null | Default | Semantic Type | -+--------------+----------------------+-----+------+---------+---------------+ -| peer_id | Int64 | | NO | | FIELD | -| peer_type | String | | NO | | FIELD | -| peer_addr | String | | YES | | FIELD | -| cpus | UInt32 | | NO | | FIELD | -| memory_bytes | UInt64 | | NO | | FIELD | -| version | String | | NO | | FIELD | -| git_commit | String | | NO | | FIELD | -| start_time | TimestampMillisecond | | YES | | FIELD | -| uptime | String | | YES | | FIELD | -| active_time | String | | YES | | FIELD | -| node_status | String | | YES | | FIELD | -| hostname | String | | YES | | FIELD | -+--------------+----------------------+-----+------+---------+---------------+ ++---------------+----------------------+-----+------+---------+---------------+ +| Column | Type | Key | Null | Default | Semantic Type | ++---------------+----------------------+-----+------+---------+---------------+ +| peer_id | Int64 | | NO | | FIELD | +| peer_type | String | | NO | | FIELD | +| peer_addr | String | | YES | | FIELD | +| peer_hostname | String | | YES | | FIELD | +| cpus | UInt32 | | NO | | FIELD | +| memory_bytes | UInt64 | | NO | | FIELD | +| version | String | | NO | | FIELD | +| git_commit | String | | NO | | FIELD | +| start_time | TimestampMillisecond | | YES | | FIELD | +| uptime | String | | YES | | FIELD | +| active_time | String | | YES | | FIELD | +| node_status | String | | YES | | FIELD | ++---------------+----------------------+-----+------+---------+---------------+ -- SQLNESS REPLACE version node_version -- SQLNESS REPLACE (\s\d+\.\d+(?:\.\d+)+\s) Version diff --git a/tests/cases/standalone/common/system/information_schema.result b/tests/cases/standalone/common/system/information_schema.result index b38b104d8236..6e5a3a5466b9 100644 --- a/tests/cases/standalone/common/system/information_schema.result +++ b/tests/cases/standalone/common/system/information_schema.result @@ -71,18 +71,18 @@ select * from information_schema.columns order by table_schema, table_name, colu | greptime | information_schema | check_constraints | constraint_catalog | 1 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | check_constraints | constraint_name | 3 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | check_constraints | constraint_schema | 2 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | -| greptime | information_schema | cluster_info | active_time | 10 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | -| greptime | information_schema | cluster_info | cpus | 4 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | No | int unsigned | | | -| greptime | information_schema | cluster_info | git_commit | 7 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | -| greptime | information_schema | cluster_info | hostname | 12 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | -| greptime | information_schema | cluster_info | memory_bytes | 5 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | No | bigint unsigned | | | -| greptime | information_schema | cluster_info | node_status | 11 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | +| greptime | information_schema | cluster_info | active_time | 11 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | +| greptime | information_schema | cluster_info | cpus | 5 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | No | int unsigned | | | +| greptime | information_schema | cluster_info | git_commit | 8 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | cluster_info | memory_bytes | 6 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | No | bigint unsigned | | | +| greptime | information_schema | cluster_info | node_status | 12 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | | greptime | information_schema | cluster_info | peer_addr | 3 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | +| greptime | information_schema | cluster_info | peer_hostname | 4 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | | greptime | information_schema | cluster_info | peer_id | 1 | | | 19 | 0 | | | | | | select,insert | | Int64 | bigint | FIELD | | No | bigint | | | | greptime | information_schema | cluster_info | peer_type | 2 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | -| greptime | information_schema | cluster_info | start_time | 8 | | | | | 3 | | | | | select,insert | | TimestampMillisecond | timestamp(3) | FIELD | | Yes | timestamp(3) | | | -| greptime | information_schema | cluster_info | uptime | 9 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | -| greptime | information_schema | cluster_info | version | 6 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | cluster_info | start_time | 9 | | | | | 3 | | | | | select,insert | | TimestampMillisecond | timestamp(3) | FIELD | | Yes | timestamp(3) | | | +| greptime | information_schema | cluster_info | uptime | 10 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | +| greptime | information_schema | cluster_info | version | 7 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | collation_character_set_applicability | character_set_name | 2 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | collation_character_set_applicability | collation_name | 1 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | collations | character_set_name | 2 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | diff --git a/tests/cases/standalone/information_schema/cluster_info.result b/tests/cases/standalone/information_schema/cluster_info.result index 6c0ab9a49b2f..6625007a3543 100644 --- a/tests/cases/standalone/information_schema/cluster_info.result +++ b/tests/cases/standalone/information_schema/cluster_info.result @@ -4,22 +4,22 @@ Affected Rows: 0 DESC TABLE CLUSTER_INFO; -+--------------+----------------------+-----+------+---------+---------------+ -| Column | Type | Key | Null | Default | Semantic Type | -+--------------+----------------------+-----+------+---------+---------------+ -| peer_id | Int64 | | NO | | FIELD | -| peer_type | String | | NO | | FIELD | -| peer_addr | String | | YES | | FIELD | -| cpus | UInt32 | | NO | | FIELD | -| memory_bytes | UInt64 | | NO | | FIELD | -| version | String | | NO | | FIELD | -| git_commit | String | | NO | | FIELD | -| start_time | TimestampMillisecond | | YES | | FIELD | -| uptime | String | | YES | | FIELD | -| active_time | String | | YES | | FIELD | -| node_status | String | | YES | | FIELD | -| hostname | String | | YES | | FIELD | -+--------------+----------------------+-----+------+---------+---------------+ ++---------------+----------------------+-----+------+---------+---------------+ +| Column | Type | Key | Null | Default | Semantic Type | ++---------------+----------------------+-----+------+---------+---------------+ +| peer_id | Int64 | | NO | | FIELD | +| peer_type | String | | NO | | FIELD | +| peer_addr | String | | YES | | FIELD | +| peer_hostname | String | | YES | | FIELD | +| cpus | UInt32 | | NO | | FIELD | +| memory_bytes | UInt64 | | NO | | FIELD | +| version | String | | NO | | FIELD | +| git_commit | String | | NO | | FIELD | +| start_time | TimestampMillisecond | | YES | | FIELD | +| uptime | String | | YES | | FIELD | +| active_time | String | | YES | | FIELD | +| node_status | String | | YES | | FIELD | ++---------------+----------------------+-----+------+---------+---------------+ -- SQLNESS REPLACE version node_version -- SQLNESS REPLACE (\d+\.\d+(?:\.\d+)+) Version From 8ee6cb6d70bdbc24e9e386c4f423ef09d8bc1936 Mon Sep 17 00:00:00 2001 From: zyy17 Date: Wed, 15 Oct 2025 22:43:43 +0800 Subject: [PATCH 4/5] chore: update greptime-proto Signed-off-by: zyy17 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/api/src/helper.rs | 2 ++ src/common/macro/src/row/schema.rs | 1 + src/frontend/src/limiter.rs | 1 + src/meta-srv/src/metasrv.rs | 10 ++++++++++ src/store-api/src/region_request.rs | 1 - 7 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5f18867da36..43c69b5c4347 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5328,7 +5328,7 @@ dependencies = [ [[package]] name = "greptime-proto" version = "0.1.0" -source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=1e291dda3b94ae3d6cfde32dd8f6be71154c13cd#1e291dda3b94ae3d6cfde32dd8f6be71154c13cd" +source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=8d31a8cd39a458ed6f2eee39fa07447f30204306#8d31a8cd39a458ed6f2eee39fa07447f30204306" dependencies = [ "prost 0.13.5", "prost-types 0.13.5", diff --git a/Cargo.toml b/Cargo.toml index f8eb0f14dbc8..b72d84f4fc91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -147,7 +147,7 @@ etcd-client = { git = "https://github.com/GreptimeTeam/etcd-client", rev = "f62d fst = "0.4.7" futures = "0.3" futures-util = "0.3" -greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "1e291dda3b94ae3d6cfde32dd8f6be71154c13cd" } +greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "8d31a8cd39a458ed6f2eee39fa07447f30204306" } hex = "0.4" http = "1" humantime = "2.1" diff --git a/src/api/src/helper.rs b/src/api/src/helper.rs index 868684ab0e04..86b01c5cc350 100644 --- a/src/api/src/helper.rs +++ b/src/api/src/helper.rs @@ -750,6 +750,7 @@ pub fn pb_value_to_value_ref<'a>( }; ValueRef::Struct(struct_value_ref) } + ValueData::JsonValue(_) => todo!(), } } @@ -924,6 +925,7 @@ pub fn proto_value_type(value: &v1::Value) -> Option { ValueData::Decimal128Value(_) => ColumnDataType::Decimal128, ValueData::ListValue(_) => ColumnDataType::List, ValueData::StructValue(_) => ColumnDataType::Struct, + ValueData::JsonValue(_) => todo!(), }; Some(value_type) } diff --git a/src/common/macro/src/row/schema.rs b/src/common/macro/src/row/schema.rs index 5e296c86004f..0f4871ea3e22 100644 --- a/src/common/macro/src/row/schema.rs +++ b/src/common/macro/src/row/schema.rs @@ -108,6 +108,7 @@ fn impl_schema_method(fields: &[ParsedField<'_>]) -> Result { Some(ColumnDataTypeExtension { type_ext: Some(TypeExt::StructType(StructTypeExtension { fields: [#(#fields),*] })) }) } } + Some(TypeExt::JsonNativeType(_)) => todo!(), None => { quote! { None } } diff --git a/src/frontend/src/limiter.rs b/src/frontend/src/limiter.rs index 8c728c42c7ce..088fe3ffa421 100644 --- a/src/frontend/src/limiter.rs +++ b/src/frontend/src/limiter.rs @@ -229,6 +229,7 @@ impl Limiter { .unwrap_or(0) }) .sum(), + ValueData::JsonValue(_) => todo!(), } } } diff --git a/src/meta-srv/src/metasrv.rs b/src/meta-srv/src/metasrv.rs index 721e21428cf3..4c2c7fcf5339 100644 --- a/src/meta-srv/src/metasrv.rs +++ b/src/meta-srv/src/metasrv.rs @@ -383,6 +383,8 @@ pub struct MetasrvNodeInfo { pub hostname: String, } +// TODO(zyy17): Allow deprecated fields for backward compatibility. Remove this when the deprecated top-level fields are removed from the proto. +#[allow(deprecated)] impl From for api::v1::meta::MetasrvNodeInfo { fn from(node_info: MetasrvNodeInfo) -> Self { Self { @@ -390,6 +392,14 @@ impl From for api::v1::meta::MetasrvNodeInfo { addr: node_info.addr, ..Default::default() }), + // TODO(zyy17): The following top-level fields are deprecated. They are kept for backward compatibility and will be removed in a future version. + // New code should use the fields in `info.NodeInfo` instead. + version: node_info.version.clone(), + git_commit: node_info.git_commit.clone(), + start_time_ms: node_info.start_time_ms, + cpus: node_info.cpus, + memory_bytes: node_info.memory_bytes, + // The canonical location for node information. info: Some(api::v1::meta::NodeInfo { version: node_info.version, git_commit: node_info.git_commit, diff --git a/src/store-api/src/region_request.rs b/src/store-api/src/region_request.rs index ef64c45a59b5..009cb4eeaff0 100644 --- a/src/store-api/src/region_request.rs +++ b/src/store-api/src/region_request.rs @@ -178,7 +178,6 @@ impl RegionRequest { reason: "ListMetadata request should be handled separately by RegionServer", } .fail(), - region_request::Body::BuildIndex(_) => todo!(), } } From 766447d5998105597bad462798dbcd3e67ab8ff7 Mon Sep 17 00:00:00 2001 From: zyy17 Date: Thu, 16 Oct 2025 11:34:34 +0800 Subject: [PATCH 5/5] chore: add the compatibility for old proto Signed-off-by: zyy17 --- src/meta-client/src/client.rs | 74 ++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/src/meta-client/src/client.rs b/src/meta-client/src/client.rs index b64b648219fc..2a66c1570af5 100644 --- a/src/meta-client/src/client.rs +++ b/src/meta-client/src/client.rs @@ -353,6 +353,8 @@ impl ProcedureExecutor for MetaClient { } } +// TODO(zyy17): Allow deprecated fields for backward compatibility. Remove this when the deprecated fields are removed from the proto. +#[allow(deprecated)] #[async_trait::async_trait] impl ClusterInfo for MetaClient { type Error = Error; @@ -373,31 +375,59 @@ impl ClusterInfo for MetaClient { followers .into_iter() .map(|node| { - let node_info = node.info.unwrap_or_default(); - NodeInfo { - peer: node.peer.unwrap_or_default(), - last_activity_ts, - status: NodeStatus::Metasrv(MetasrvStatus { is_leader: false }), - version: node_info.version, - git_commit: node_info.git_commit, - start_time_ms: node_info.start_time_ms, - cpus: node_info.cpus, - memory_bytes: node_info.memory_bytes, - hostname: node_info.hostname, + if let Some(node_info) = node.info { + NodeInfo { + peer: node.peer.unwrap_or_default(), + last_activity_ts, + status: NodeStatus::Metasrv(MetasrvStatus { is_leader: false }), + version: node_info.version, + git_commit: node_info.git_commit, + start_time_ms: node_info.start_time_ms, + cpus: node_info.cpus, + memory_bytes: node_info.memory_bytes, + hostname: node_info.hostname, + } + } else { + // TODO(zyy17): It's for backward compatibility. Remove this when the deprecated fields are removed from the proto. + NodeInfo { + peer: node.peer.unwrap_or_default(), + last_activity_ts, + status: NodeStatus::Metasrv(MetasrvStatus { is_leader: false }), + version: node.version, + git_commit: node.git_commit, + start_time_ms: node.start_time_ms, + cpus: node.cpus, + memory_bytes: node.memory_bytes, + hostname: "".to_string(), + } } }) .chain(leader.into_iter().map(|node| { - let node_info = node.info.unwrap_or_default(); - NodeInfo { - peer: node.peer.unwrap_or_default(), - last_activity_ts, - status: NodeStatus::Metasrv(MetasrvStatus { is_leader: true }), - version: node_info.version, - git_commit: node_info.git_commit, - start_time_ms: node_info.start_time_ms, - cpus: node_info.cpus, - memory_bytes: node_info.memory_bytes, - hostname: node_info.hostname, + if let Some(node_info) = node.info { + NodeInfo { + peer: node.peer.unwrap_or_default(), + last_activity_ts, + status: NodeStatus::Metasrv(MetasrvStatus { is_leader: true }), + version: node_info.version, + git_commit: node_info.git_commit, + start_time_ms: node_info.start_time_ms, + cpus: node_info.cpus, + memory_bytes: node_info.memory_bytes, + hostname: node_info.hostname, + } + } else { + // TODO(zyy17): It's for backward compatibility. Remove this when the deprecated fields are removed from the proto. + NodeInfo { + peer: node.peer.unwrap_or_default(), + last_activity_ts, + status: NodeStatus::Metasrv(MetasrvStatus { is_leader: true }), + version: node.version, + git_commit: node.git_commit, + start_time_ms: node.start_time_ms, + cpus: node.cpus, + memory_bytes: node.memory_bytes, + hostname: "".to_string(), + } } })) .collect::>()