Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: linning <linningde25@gmail.com>
  • Loading branch information
NingLin-P committed Mar 24, 2022
1 parent 791566e commit e049c24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 5 additions & 4 deletions components/raftstore/src/store/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,10 +992,11 @@ where
PeerState::Tombstone,
// Only persist the `merge_state` if the merge is known to be succeeded
// which is determined by the `keep_data` flag
self.pending_merge_state
.as_ref()
.filter(|_| keep_data)
.cloned(),
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
7 changes: 2 additions & 5 deletions tests/failpoints/cases/test_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1676,10 +1676,7 @@ fn test_destroy_source_peer_while_merging() {
let pd_client = Arc::clone(&cluster.pd_client);
pd_client.disable_default_operator();

let r1 = cluster.run_conf_change();
for i in 2..=5 {
pd_client.must_add_peer(r1, new_peer(i, i));
}
cluster.run();

cluster.must_put(b"k1", b"v1");
cluster.must_put(b"k3", b"v3");
Expand Down Expand Up @@ -1729,7 +1726,6 @@ fn test_destroy_source_peer_while_merging() {
// but it is still in tombstone state due to the message filter
let state = cluster.region_local_state(right.get_id(), 5);
assert_eq!(state.get_state(), PeerState::Tombstone);
assert!(!state.has_merge_state(), "{:?}", state);

// let the peer on store 4 have a larger peer id
pd_client.must_remove_peer(right.get_id(), new_peer(4, 4));
Expand All @@ -1743,6 +1739,7 @@ fn test_destroy_source_peer_while_merging() {
cluster.add_send_filter(IsolationFilterFactory::new(1));

cluster.must_put(b"k5", b"v5");
assert!(!state.has_merge_state(), "{:?}", state);
for i in 2..=5 {
must_get_equal(&cluster.get_engine(i), b"k5", b"v5");
}
Expand Down

0 comments on commit e049c24

Please sign in to comment.