From 6b5a8b24f0168262012d04c56463f8c8c1d17553 Mon Sep 17 00:00:00 2001 From: Calvin Neo Date: Fri, 20 Sep 2024 14:32:07 +0800 Subject: [PATCH] Compaction for FAP serverless including txn file ref, shard_ver and enc key (#397) Signed-off-by: Calvin Neo --- .../engine_store_ffi/src/core/fast_add_peer.rs | 17 +++++++++++++---- .../engine_store_ffi/src/core/mod.rs | 1 + .../src/core/serverless_extra.rs | 17 +++++++++++++++++ .../src/mock_store/mock_fast_add_peer_impls.rs | 8 ++++++++ proxy_components/proxy_ffi/src/interfaces.rs | 6 +++++- .../ffi/src/RaftStoreProxyFFI/@version | 2 +- .../ffi/src/RaftStoreProxyFFI/ProxyFFI.h | 4 ++++ 7 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 proxy_components/engine_store_ffi/src/core/serverless_extra.rs diff --git a/proxy_components/engine_store_ffi/src/core/fast_add_peer.rs b/proxy_components/engine_store_ffi/src/core/fast_add_peer.rs index 49d201ba7cd..8376cf30a00 100644 --- a/proxy_components/engine_store_ffi/src/core/fast_add_peer.rs +++ b/proxy_components/engine_store_ffi/src/core/fast_add_peer.rs @@ -1,6 +1,6 @@ // Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0. use crate::{ - core::{common::*, ProxyForwarder}, + core::{common::*, serverless_extra::*, ProxyForwarder}, ffi::interfaces_ffi::FastAddPeerStatus, }; @@ -439,7 +439,15 @@ impl ProxyForwarder { "new_region" => ?new_region, "apply_state" => ?apply_state, ); - match self.build_and_send_snapshot(region_id, new_peer_id, msg, apply_state, new_region) { + let serverless_extra = ServerlessExtra::new(&res); + match self.build_and_send_snapshot( + region_id, + new_peer_id, + msg, + apply_state, + new_region, + serverless_extra, + ) { Ok(s) => { match s { FastAddPeerStatus::Ok => { @@ -517,6 +525,7 @@ impl ProxyForwarder { msg: &RaftMessage, apply_state: RaftApplyState, new_region: kvproto::metapb::Region, + _serverless_extra: ServerlessExtra, ) -> RaftStoreResult { let cached_manager = self.get_cached_manager(); let inner_msg = msg.get_message(); @@ -623,8 +632,8 @@ impl ProxyForwarder { pb_snapshot_metadata.set_term(key.term); } - debug!( - "pb_snapshot_data {:?} pb_snapshot_metadata {:?}", + info!( + "fast path: pb_snapshot_data {:?} pb_snapshot_metadata {:?}", pb_snapshot_data, pb_snapshot_metadata ); diff --git a/proxy_components/engine_store_ffi/src/core/mod.rs b/proxy_components/engine_store_ffi/src/core/mod.rs index b60e037304a..81e0b0ddf23 100644 --- a/proxy_components/engine_store_ffi/src/core/mod.rs +++ b/proxy_components/engine_store_ffi/src/core/mod.rs @@ -4,6 +4,7 @@ pub(crate) mod common; pub mod fast_add_peer; pub mod forward_raft; pub mod forwarder; +pub mod serverless_extra; pub use fast_add_peer::*; pub use forward_raft::*; diff --git a/proxy_components/engine_store_ffi/src/core/serverless_extra.rs b/proxy_components/engine_store_ffi/src/core/serverless_extra.rs new file mode 100644 index 00000000000..e9632821fd0 --- /dev/null +++ b/proxy_components/engine_store_ffi/src/core/serverless_extra.rs @@ -0,0 +1,17 @@ +// Copyright 2024 TiKV Project Authors. Licensed under Apache-2.0. + +use crate::ffi::interfaces_ffi::FastAddPeerRes; + +#[derive(Default)] +pub struct ServerlessExtra { + _shard_ver: u64, + _inner_key: Vec, + _enc_key: Vec, + _txn_file_ref: Vec, +} + +impl ServerlessExtra { + pub fn new(_res: &FastAddPeerRes) -> Self { + Default::default() + } +} diff --git a/proxy_components/mock-engine-store/src/mock_store/mock_fast_add_peer_impls.rs b/proxy_components/mock-engine-store/src/mock_store/mock_fast_add_peer_impls.rs index 520e7e09cdb..f970db7bf81 100644 --- a/proxy_components/mock-engine-store/src/mock_store/mock_fast_add_peer_impls.rs +++ b/proxy_components/mock-engine-store/src/mock_store/mock_fast_add_peer_impls.rs @@ -133,6 +133,10 @@ pub(crate) unsafe extern "C" fn ffi_fast_add_peer( status, apply_state: create_cpp_str(None), region: create_cpp_str(None), + shard_ver: 0, + inner_key: create_cpp_str(None), + enc_key: create_cpp_str(None), + txn_file_ref: create_cpp_str(None), }; let from_store = (|| { fail::fail_point!("fap_mock_add_peer_from_id", |t| { @@ -313,6 +317,10 @@ pub(crate) unsafe extern "C" fn ffi_fast_add_peer( status: interfaces_ffi::FastAddPeerStatus::Ok, apply_state: apply_state_ptr, region: region_ptr, + shard_ver: 0, + inner_key: create_cpp_str(None), + enc_key: create_cpp_str(None), + txn_file_ref: create_cpp_str(None), }); }); if let Some(r) = ret { diff --git a/proxy_components/proxy_ffi/src/interfaces.rs b/proxy_components/proxy_ffi/src/interfaces.rs index ca2e9337c6f..4b87b425fd8 100644 --- a/proxy_components/proxy_ffi/src/interfaces.rs +++ b/proxy_components/proxy_ffi/src/interfaces.rs @@ -361,6 +361,10 @@ pub mod root { pub status: root::DB::FastAddPeerStatus, pub apply_state: root::DB::CppStrWithView, pub region: root::DB::CppStrWithView, + pub shard_ver: u64, + pub inner_key: root::DB::CppStrWithView, + pub enc_key: root::DB::CppStrWithView, + pub txn_file_ref: root::DB::CppStrWithView, } #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -789,7 +793,7 @@ pub mod root { arg3: root::DB::RawVoidPtr, ) -> u32; } - pub const RAFT_STORE_PROXY_VERSION: u64 = 9679186549381427051; + pub const RAFT_STORE_PROXY_VERSION: u64 = 2149052863435660119; pub const RAFT_STORE_PROXY_MAGIC_NUMBER: u32 = 324508639; } } diff --git a/raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version b/raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version index 59c3d0bca37..10aed53e70b 100644 --- a/raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version +++ b/raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version @@ -1,3 +1,3 @@ #pragma once #include -namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 9679186549381427051ull; } \ No newline at end of file +namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 2149052863435660119ull; } \ No newline at end of file diff --git a/raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h b/raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h index 3dd1feba12a..5a3cbaf4817 100644 --- a/raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h +++ b/raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h @@ -243,6 +243,10 @@ struct FastAddPeerRes { FastAddPeerStatus status; CppStrWithView apply_state; CppStrWithView region; + uint64_t shard_ver; + CppStrWithView inner_key; + CppStrWithView enc_key; + CppStrWithView txn_file_ref; }; enum class FapSnapshotState : uint32_t {