diff --git a/components/raftstore/src/engine_store_ffi/mod.rs b/components/raftstore/src/engine_store_ffi/mod.rs index dd520a7b8f1..9016e478af9 100644 --- a/components/raftstore/src/engine_store_ffi/mod.rs +++ b/components/raftstore/src/engine_store_ffi/mod.rs @@ -27,13 +27,13 @@ use kvproto::{kvrpcpb, metapb, raft_cmdpb}; use protobuf::Message; pub use read_index_helper::ReadIndexClient; -pub use crate::engine_store_ffi::interfaces::root::DB::{ +pub use self::interfaces::root::DB::{ BaseBuffView, ColumnFamilyType, CppStrVecView, EngineStoreApplyRes, EngineStoreServerHelper, EngineStoreServerStatus, FileEncryptionRes, FsStats, HttpRequestRes, HttpRequestStatus, KVGetStatus, RaftCmdHeader, RaftProxyStatus, RaftStoreProxyFFIHelper, RawCppPtr, RawCppStringPtr, RawVoidPtr, SSTReaderPtr, StoreStats, WriteCmdType, WriteCmdsView, }; -use crate::engine_store_ffi::{ +use self::{ interfaces::root::DB::{ ConstRawVoidPtr, FileEncryptionInfoRaw, RaftStoreProxyPtr, RawCppPtrType, RawRustPtr, SSTReaderInterfaces, SSTView, SSTViewVec, RAFT_STORE_PROXY_MAGIC_NUMBER, @@ -276,7 +276,7 @@ impl Into for RawRustPtrType { pub extern "C" fn ffi_gc_rust_ptr( data: RawVoidPtr, - type_: crate::engine_store_ffi::interfaces::root::DB::RawRustPtrType, + type_: self::interfaces::root::DB::RawRustPtrType, ) { if data.is_null() { return; @@ -385,9 +385,7 @@ pub extern "C" fn ffi_poll_read_index_task( _ => {} } } - let task = unsafe { - &mut *(task_ptr as *mut crate::engine_store_ffi::read_index_helper::ReadIndexTask) - }; + let task = unsafe { &mut *(task_ptr as *mut self::read_index_helper::ReadIndexTask) }; let waker = if std::ptr::null_mut() == waker { None } else { diff --git a/components/raftstore/src/engine_store_ffi/observer.rs b/components/raftstore/src/engine_store_ffi/observer.rs index cd1febb0653..e9892fa72df 100644 --- a/components/raftstore/src/engine_store_ffi/observer.rs +++ b/components/raftstore/src/engine_store_ffi/observer.rs @@ -737,6 +737,7 @@ impl ApplySnapshotObserver for TiFlashObserver { info!("background pre-handle snapshot get error"; "snap_key" => ?snap_key, "region" => ?ob_ctx.region(), + "pending" => self.engine.pending_applies_count.load(Ordering::SeqCst), ); true } @@ -754,6 +755,11 @@ impl ApplySnapshotObserver for TiFlashObserver { None => { // We can't find background pre-handle task, // maybe we can't get snapshot at that time. + info!("pre-handled snapshot not found"; + "snap_key" => ?snap_key, + "region" => ?ob_ctx.region(), + "pending" => self.engine.pending_applies_count.load(Ordering::SeqCst), + ); true } }; @@ -772,12 +778,12 @@ impl ApplySnapshotObserver for TiFlashObserver { ); self.engine_store_server_helper .apply_pre_handled_snapshot(ptr.0); + info!("apply snapshot finished"; + "peer_id" => ?snap_key, + "region" => ?ob_ctx.region(), + "pending" => self.engine.pending_applies_count.load(Ordering::SeqCst), + ); } - info!("apply snapshot finished"; - "peer_id" => ?peer_id, - "region" => ?ob_ctx.region(), - "pending" => self.engine.pending_applies_count.load(Ordering::SeqCst), - ); Ok(()) } diff --git a/components/raftstore/src/store/fsm/apply.rs b/components/raftstore/src/store/fsm/apply.rs index 90800cca0aa..30f10f82dcf 100644 --- a/components/raftstore/src/store/fsm/apply.rs +++ b/components/raftstore/src/store/fsm/apply.rs @@ -75,9 +75,6 @@ use crate::{ ApplyCtxInfo, Cmd, CmdBatch, CmdObserveInfo, CoprocessorHost, ObserveHandle, ObserveLevel, RegionState, }, - engine_store_ffi::{ - ColumnFamilyType, EngineStoreApplyRes, RaftCmdHeader, WriteCmdType, WriteCmds, - }, store::{ cmd_resp, fsm::RaftPollerBuilder, diff --git a/components/raftstore/src/store/snap.rs b/components/raftstore/src/store/snap.rs index abe8c60cd65..1001b1e2db1 100644 --- a/components/raftstore/src/store/snap.rs +++ b/components/raftstore/src/store/snap.rs @@ -45,7 +45,6 @@ use tikv_util::{ use crate::{ coprocessor::CoprocessorHost, - engine_store_ffi, store::{ metrics::{ CfNames, INGEST_SST_DURATION_SECONDS, SNAPSHOT_BUILD_TIME_HISTOGRAM, @@ -450,14 +449,6 @@ pub struct Snapshot { mgr: SnapManagerCore, } -pub struct PreHandledSnapshot { - pub index: u64, - pub term: u64, - pub inner: engine_store_ffi::RawCppPtr, -} - -unsafe impl Send for PreHandledSnapshot {} - #[derive(PartialEq, Eq, Clone, Copy)] enum CheckPolicy { ErrAllowed, diff --git a/components/raftstore/src/store/worker/region.rs b/components/raftstore/src/store/worker/region.rs index 19fc3714217..be34d30ad71 100644 --- a/components/raftstore/src/store/worker/region.rs +++ b/components/raftstore/src/store/worker/region.rs @@ -43,7 +43,7 @@ use crate::{ JOB_STATUS_CANCELLED, JOB_STATUS_CANCELLING, JOB_STATUS_FAILED, JOB_STATUS_FINISHED, JOB_STATUS_PENDING, JOB_STATUS_RUNNING, }, - snap::{plain_file_used, Error, PreHandledSnapshot, Result, SNAPSHOT_CFS}, + snap::{plain_file_used, Error, Result, SNAPSHOT_CFS}, transport::CasualRouter, ApplyOptions, CasualMessage, SnapEntry, SnapKey, SnapManager, }, @@ -119,8 +119,6 @@ struct EngineStoreApplySnapTask { region_id: u64, peer_id: u64, status: Arc, - recv: mpsc::Receiver>, - pre_handled_snap: Option, } #[derive(Clone)] @@ -737,8 +735,8 @@ where pool_size, pre_handle_snap, }, - pool: Builder::new(thd_name!("region-task")) - .max_thread_count(pool_size) + pool: Builder::new(thd_name!("snap-generator")) + .max_thread_count(snap_generator_pool_size) .build_future_pool(), ctx: SnapContext { engine,