Skip to content

Commit

Permalink
cherry pick tikv#12251 to release-5.1
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
NingLin-P authored and ti-srebot committed Mar 28, 2022
1 parent 80ce934 commit 4789cb9
Show file tree
Hide file tree
Showing 3 changed files with 471 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/raftstore/src/store/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,13 @@ where
&mut kv_wb,
&region,
PeerState::Tombstone,
self.pending_merge_state.clone(),
// Only persist the `merge_state` if the merge is known to be succeeded
// which is determined by the `keep_data` flag
if keep_data {
self.pending_merge_state.clone()
} else {
None
},
)?;
// write kv rocksdb first in case of restart happen between two write
let mut write_opts = WriteOptions::new();
Expand Down
22 changes: 22 additions & 0 deletions components/test_raftstore/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,28 @@ impl<T: Simulator> Cluster<T> {
.unwrap()
}

pub fn must_peer_state(&self, region_id: u64, store_id: u64, peer_state: PeerState) {
for _ in 0..100 {
let state = self
.get_engine(store_id)
.c()
.get_msg_cf::<RegionLocalState>(
engine_traits::CF_RAFT,
&keys::region_state_key(region_id),
)
.unwrap()
.unwrap();
if state.get_state() == peer_state {
return;
}
sleep_ms(10);
}
panic!(
"[region {}] peer state still not reach {:?}",
region_id, peer_state
);
}

pub fn wait_last_index(
&mut self,
region_id: u64,
Expand Down
Loading

0 comments on commit 4789cb9

Please sign in to comment.