Skip to content

Commit

Permalink
pass ut and add comment for flush epoch
Browse files Browse the repository at this point in the history
Signed-off-by: bufferflies <1045931706@qq.com>
  • Loading branch information
bufferflies committed Jul 10, 2023
1 parent 529fe6c commit 725351a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/raftstore-v2/src/operation/ready/apply_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ impl<EK: KvEngine, ER: RaftEngine> Storage<EK, ER> {
}
let region_id = self.region().get_id();
let raft_engine = self.entry_storage().raft_engine();
// must use the persistent epoch to avoid epoch rollback, the restart
// logic can see ApplyTrace::recover. self.epoch is not reliable because
// it maybe too newest, so the epoch maybe rollback after the node restarted.
let epoch = raft_engine
.get_region_state(region_id, trace.admin.flushed)
.unwrap()
Expand Down Expand Up @@ -646,6 +649,7 @@ impl<EK: KvEngine, ER: RaftEngine> Peer<EK, ER> {
let mut lb = ctx.engine.log_batch(1);
lb.put_flushed_index(region_id, CF_RAFT, tablet_index, admin_flush)
.unwrap();
ctx.engine.consume(&mut lb, true).unwrap();
info!(
self.logger,
"flush before close flush admin for region";
Expand Down
1 change: 1 addition & 0 deletions components/raftstore-v2/src/raft/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub struct Storage<EK: KvEngine, ER> {
/// The flushed index of all CFs.
apply_trace: ApplyTrace,
// The flushed epoch means that the epoch has persisted into the raft engine.
// raft epoch >= engine epoch >= flushed epoch
flushed_epoch: RegionEpoch,
}

Expand Down

0 comments on commit 725351a

Please sign in to comment.