Skip to content

Commit

Permalink
Compaction for FAP serverless including txn file ref, shard_ver and e…
Browse files Browse the repository at this point in the history
…nc key (#397)

 

Signed-off-by: Calvin Neo <[email protected]>
  • Loading branch information
CalvinNeo authored Sep 20, 2024
1 parent 32ce500 commit 6b5a8b2
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 6 deletions.
17 changes: 13 additions & 4 deletions proxy_components/engine_store_ffi/src/core/fast_add_peer.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand Down Expand Up @@ -439,7 +439,15 @@ impl<T: Transport + 'static, ER: RaftEngine> ProxyForwarder<T, ER> {
"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 => {
Expand Down Expand Up @@ -517,6 +525,7 @@ impl<T: Transport + 'static, ER: RaftEngine> ProxyForwarder<T, ER> {
msg: &RaftMessage,
apply_state: RaftApplyState,
new_region: kvproto::metapb::Region,
_serverless_extra: ServerlessExtra,
) -> RaftStoreResult<FastAddPeerStatus> {
let cached_manager = self.get_cached_manager();
let inner_msg = msg.get_message();
Expand Down Expand Up @@ -623,8 +632,8 @@ impl<T: Transport + 'static, ER: RaftEngine> ProxyForwarder<T, ER> {
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
);

Expand Down
1 change: 1 addition & 0 deletions proxy_components/engine_store_ffi/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
17 changes: 17 additions & 0 deletions proxy_components/engine_store_ffi/src/core/serverless_extra.rs
Original file line number Diff line number Diff line change
@@ -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<u8>,
_enc_key: Vec<u8>,
_txn_file_ref: Vec<u8>,
}

impl ServerlessExtra {
pub fn new(_res: &FastAddPeerRes) -> Self {
Default::default()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion proxy_components/proxy_ffi/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion raftstore-proxy/ffi/src/RaftStoreProxyFFI/@version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once
#include <cstdint>
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 9679186549381427051ull; }
namespace DB { constexpr uint64_t RAFT_STORE_PROXY_VERSION = 2149052863435660119ull; }
4 changes: 4 additions & 0 deletions raftstore-proxy/ffi/src/RaftStoreProxyFFI/ProxyFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6b5a8b2

Please sign in to comment.