Skip to content

Commit

Permalink
This is an automated cherry-pick of tikv#16641
Browse files Browse the repository at this point in the history
close tikv#16639

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
Connor1996 authored and ti-chi-bot committed Apr 19, 2024
1 parent c00d501 commit 31b050b
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions components/raftstore/src/store/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@ pub struct InspectedRaftMessage {

/// Message that can be sent to a peer.
#[allow(clippy::large_enum_variant)]
<<<<<<< HEAD
=======
#[derive(EnumCount, EnumVariantNames)]
>>>>>>> 19affe077f (raftstore: Fix store msg discriminant out of bound (#16641))
pub enum PeerMsg<EK: KvEngine> {
/// Raft message is the message sent between raft nodes in the same
/// raft group. Messages need to be redirected to raftstore if target
Expand Down Expand Up @@ -861,10 +865,6 @@ where
inspector: LatencyInspector,
},

/// Message only used for test.
#[cfg(any(test, feature = "testexport"))]
Validate(Box<dyn FnOnce(&crate::store::Config) + Send>),

UnsafeRecoveryReport(pdpb::StoreReport),
UnsafeRecoveryCreatePeer {
syncer: UnsafeRecoveryExecutePlanSyncer,
Expand All @@ -876,6 +876,10 @@ where
AwakenRegions {
abnormal_stores: Vec<u64>,
},

/// Message only used for test.
#[cfg(any(test, feature = "testexport"))]
Validate(Box<dyn FnOnce(&crate::store::Config) + Send>),
}

impl<EK: KvEngine> ResourceMetered for StoreMsg<EK> {}
Expand All @@ -901,8 +905,6 @@ where
),
StoreMsg::Tick(tick) => write!(fmt, "StoreTick {:?}", tick),
StoreMsg::Start { ref store } => write!(fmt, "Start store {:?}", store),
#[cfg(any(test, feature = "testexport"))]
StoreMsg::Validate(_) => write!(fmt, "Validate config"),
StoreMsg::UpdateReplicationMode(_) => write!(fmt, "UpdateReplicationMode"),
StoreMsg::LatencyInspect { .. } => write!(fmt, "LatencyInspect"),
StoreMsg::UnsafeRecoveryReport(..) => write!(fmt, "UnsafeRecoveryReport"),
Expand All @@ -911,6 +913,32 @@ where
}
StoreMsg::GcSnapshotFinish => write!(fmt, "GcSnapshotFinish"),
StoreMsg::AwakenRegions { .. } => write!(fmt, "AwakenRegions"),
#[cfg(any(test, feature = "testexport"))]
StoreMsg::Validate(_) => write!(fmt, "Validate config"),
}
}
}
<<<<<<< HEAD
=======

impl<EK: KvEngine> StoreMsg<EK> {
pub fn discriminant(&self) -> usize {
match self {
StoreMsg::RaftMessage(_) => 0,
StoreMsg::StoreUnreachable { .. } => 1,
StoreMsg::CompactedEvent(_) => 2,
StoreMsg::ClearRegionSizeInRange { .. } => 3,
StoreMsg::Tick(_) => 4,
StoreMsg::Start { .. } => 5,
StoreMsg::UpdateReplicationMode(_) => 6,
StoreMsg::LatencyInspect { .. } => 7,
StoreMsg::UnsafeRecoveryReport(_) => 8,
StoreMsg::UnsafeRecoveryCreatePeer { .. } => 9,
StoreMsg::GcSnapshotFinish => 10,
StoreMsg::AwakenRegions { .. } => 11,
#[cfg(any(test, feature = "testexport"))]
StoreMsg::Validate(_) => 12, // Please keep this always be the last one.
}
}
}
>>>>>>> 19affe077f (raftstore: Fix store msg discriminant out of bound (#16641))

0 comments on commit 31b050b

Please sign in to comment.