From 174028fc8a49c330b5223f5ecf0132b7026787b9 Mon Sep 17 00:00:00 2001 From: Connor1996 Date: Tue, 28 Apr 2020 16:38:10 +0800 Subject: [PATCH] remove useless hints Signed-off-by: Connor1996 --- courses/project2-RaftKV.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/courses/project2-RaftKV.md b/courses/project2-RaftKV.md index dcb11bb5..fa4f7243 100644 --- a/courses/project2-RaftKV.md +++ b/courses/project2-RaftKV.md @@ -225,9 +225,4 @@ Raftstore checks whether it needs to gc log from time to time based on the confi Then due to the log compaction, Raft module maybe needs to send a snapshot. `PeerStorage` implements `Storage.Snapshot()`. TinyKV generates snapshots and applies snapshots in the region worker. When calling `Snapshot()`, it actually sends a task `RegionTaskGen` to the region worker. The message handler of the region worker is located in `kv/raftstore/runner/region_task.go`. It scans the underlying engines to generate a snapshot, and sends snapshot metadata by channel. At the next time of Raft calling `Snapshot`, it checks whether the snapshot generating is finished. If yes, Raft should send the snapshot message to other peers, and the snapshot sending and receiving work is handled by `kv/storage/raft_storage/snap_runner.go`. You don’t need to dive into the details, only should know the snapshot message will be handled by `onRaftMsg` after the snapshot is received. Then the snapshot will reflect in the next Raft ready, so the task you should do is to modify the raft ready process to handle the case of snapshot. When you are sure to apply the snapshot, you can update the peer storage’s memory state like `RaftLocalState`, `RaftApplyState` and `RegionLocalState`. Also don’t forget to persist these states to kvdb and raftdb and remove stale state from kvdb and raftdb. Besides, you also need to update -`PeerStorage.snapState` to `snap.SnapState_Applying` and send `runner.RegionTaskApply` task to region worker through `PeerStorage.regionSched` and wait until region worker finish. - -> Hints: -> -> - If there are some committed entries to be executed in the apply worker, do not apply state, see `ReadyToHandlePendingSnap`. -> - Do not handle the next Raft ready before finishing applying snapshot. +`PeerStorage.snapState` to `snap.SnapState_Applying` and send `runner.RegionTaskApply` task to region worker through `PeerStorage.regionSched` and wait until region worker finish. \ No newline at end of file