From b36e6d523c9d22c64552387cb4bf077afe25663b Mon Sep 17 00:00:00 2001 From: Zhang Yanpo Date: Wed, 4 Mar 2026 23:50:09 +0800 Subject: [PATCH 1/2] feat: add gRPC version compatibility changelog Add `GrpcVersionCompat` struct and `grpc_changelog()` function that records min-compatible client/server versions at each package version where compatibility changed. Consumers use `.range(..=v).last()` to look up the applicable entry for any historical version. Co-Authored-By: Claude Opus 4.6 --- crates/common/version/src/grpc_changelog.rs | 119 ++++++++++++++++++++ crates/common/version/src/lib.rs | 3 + 2 files changed, 122 insertions(+) create mode 100644 crates/common/version/src/grpc_changelog.rs diff --git a/crates/common/version/src/grpc_changelog.rs b/crates/common/version/src/grpc_changelog.rs new file mode 100644 index 0000000..4d3de86 --- /dev/null +++ b/crates/common/version/src/grpc_changelog.rs @@ -0,0 +1,119 @@ +// Copyright 2021 Datafuse Labs +// +// 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. + +//! Changelog of gRPC version compatibility. +//! +//! Records the minimum compatible client and server versions at each package +//! version where compatibility changed. Consumers use +//! `.range(..=v).last()` to find the applicable entry for a given version. + +use std::collections::BTreeMap; + +use crate::version::Version; + +/// Min-compatible client and server versions at a given package version. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct GrpcVersionCompat { + pub min_client: Version, + pub min_server: Version, +} + +/// Returns a changelog mapping each package version (where compatibility +/// changed) to the min-compatible client and server versions at that point. +/// +/// Only versions where `min_client` or `min_server` changed are included. +pub fn grpc_changelog() -> BTreeMap { + const fn ver(major: u64, minor: u64, patch: u64) -> Version { + Version::new(major, minor, patch) + } + + let mut m = BTreeMap::new(); + + // 260205.0.0: client adds ExpireInMillis, PutSequential (server since 1.2.770) + m.insert(ver(260205, 0, 0), GrpcVersionCompat { + min_client: ver(1, 2, 676), + min_server: ver(1, 2, 770), + }); + + // 260214.0.0: client adds KvGetMany(srv:1.2.869), TransactionPrevValue(srv:1.2.304) + m.insert(ver(260214, 0, 0), GrpcVersionCompat { + min_client: ver(1, 2, 676), + min_server: ver(1, 2, 869), + }); + + // 260217.0.0: client adds KvTransactionPutMatchSeq (server since 260217.0.0) + #[cfg(feature = "txn-put-match-seq")] + m.insert(ver(260217, 0, 0), GrpcVersionCompat { + min_client: ver(1, 2, 676), + min_server: ver(260217, 0, 0), + }); + + // 260217.0.0: without txn-put-match-seq, no new client requirement + #[cfg(not(feature = "txn-put-match-seq"))] + m.insert(ver(260217, 0, 0), GrpcVersionCompat { + min_client: ver(1, 2, 676), + min_server: ver(1, 2, 869), + }); + + m +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::MIN_CLIENT_VERSION; + use crate::MIN_SERVER_VERSION; + + #[test] + fn test_grpc_changelog_last_entry_matches_current() { + let changelog = grpc_changelog(); + let (_, last) = changelog.iter().next_back().unwrap(); + + assert_eq!( + last.min_client, MIN_CLIENT_VERSION, + "last changelog min_client must match MIN_CLIENT_VERSION" + ); + + assert_eq!( + last.min_server, MIN_SERVER_VERSION, + "last changelog min_server must match MIN_SERVER_VERSION" + ); + } + + #[test] + fn test_grpc_changelog_monotonic() { + let changelog = grpc_changelog(); + let mut prev_client = Version::min(); + let mut prev_server = Version::min(); + + for (ver, compat) in &changelog { + assert!( + compat.min_client >= prev_client, + "min_client decreased at {}: {:?} < {:?}", + ver, + compat.min_client, + prev_client + ); + assert!( + compat.min_server >= prev_server, + "min_server decreased at {}: {:?} < {:?}", + ver, + compat.min_server, + prev_server + ); + prev_client = compat.min_client; + prev_server = compat.min_server; + } + } +} diff --git a/crates/common/version/src/lib.rs b/crates/common/version/src/lib.rs index 75af7e5..2dc3f5f 100644 --- a/crates/common/version/src/lib.rs +++ b/crates/common/version/src/lib.rs @@ -32,6 +32,7 @@ //! See [Compatibility Algorithm](./compatibility_algorithm.md) for details. mod feature_span; +mod grpc_changelog; mod grpc_feat; mod grpc_spec; mod raft_feat; @@ -41,6 +42,8 @@ mod version; pub use self::feature_span::FeatureSet; pub use self::feature_span::FeatureSpan; pub use self::feature_span::FeatureSpec; +pub use self::grpc_changelog::GrpcVersionCompat; +pub use self::grpc_changelog::grpc_changelog; pub use self::grpc_feat::GrpcFeature; pub use self::grpc_spec::GrpcSpec; pub use self::raft_feat::RaftFeature; From cc64e877292f7dea133d7661b686efc016366c69 Mon Sep 17 00:00:00 2001 From: Zhang Yanpo Date: Thu, 5 Mar 2026 00:11:18 +0800 Subject: [PATCH 2/2] chore: bump version to 260304.0.0 Add changelog entry for 260304.0.0 and a test asserting the current package version is present in the gRPC compatibility changelog. Co-Authored-By: Claude Opus 4.6 --- Cargo.toml | 2 +- crates/common/version/src/grpc_changelog.rs | 25 +++++++++++++++++++++ crates/common/version/src/lib.rs | 6 ++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4e90669..bb35f89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "260217.0.0" +version = "260304.0.0" authors = ["Databend Authors "] license = "Apache-2.0" publish = false diff --git a/crates/common/version/src/grpc_changelog.rs b/crates/common/version/src/grpc_changelog.rs index 4d3de86..5cceb16 100644 --- a/crates/common/version/src/grpc_changelog.rs +++ b/crates/common/version/src/grpc_changelog.rs @@ -66,6 +66,19 @@ pub fn grpc_changelog() -> BTreeMap { min_server: ver(1, 2, 869), }); + // 260304.0.0: no compatibility change + #[cfg(feature = "txn-put-match-seq")] + m.insert(ver(260304, 0, 0), GrpcVersionCompat { + min_client: ver(1, 2, 676), + min_server: ver(260217, 0, 0), + }); + + #[cfg(not(feature = "txn-put-match-seq"))] + m.insert(ver(260304, 0, 0), GrpcVersionCompat { + min_client: ver(1, 2, 676), + min_server: ver(1, 2, 869), + }); + m } @@ -75,6 +88,18 @@ mod tests { use crate::MIN_CLIENT_VERSION; use crate::MIN_SERVER_VERSION; + #[test] + fn test_grpc_changelog_contains_current_version() { + let changelog = grpc_changelog(); + let current = *crate::version(); + + assert!( + changelog.contains_key(¤t), + "changelog must contain an entry for the current version {}", + current + ); + } + #[test] fn test_grpc_changelog_last_entry_matches_current() { let changelog = grpc_changelog(); diff --git a/crates/common/version/src/lib.rs b/crates/common/version/src/lib.rs index 2dc3f5f..643987a 100644 --- a/crates/common/version/src/lib.rs +++ b/crates/common/version/src/lib.rs @@ -131,17 +131,17 @@ mod tests { #[test] fn test_version_string() { - assert_eq!(version_str(), "260217.0.0"); + assert_eq!(version_str(), "260304.0.0"); } #[test] fn test_semver_components() { - assert_eq!(semver_tuple(version()), (260217, 0, 0)); + assert_eq!(semver_tuple(version()), (260304, 0, 0)); } #[test] fn test_semver_display() { - assert_eq!(version().to_semver().to_string(), "260217.0.0"); + assert_eq!(version().to_semver().to_string(), "260304.0.0"); } #[test]