Skip to content

Commit

Permalink
Merge pull request cockroachdb#2553 from xiang90/raft-design
Browse files Browse the repository at this point in the history
raft: add progress state machine graph
  • Loading branch information
xiang90 committed Mar 21, 2015
2 parents bee761c + bf23882 commit 42ecf74
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions design.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,35 @@ A progress has two attribute: `match` and `next`. `match` is the index of the hi

A progress is in one of the three state: `probe`, `replicate`, `snapshot`.

```
+--------------------------------------------------------+
| send snapshot |
| |
+---------+----------+ +----------v---------+
+---> probe | | snapshot |
| | max inflight = 1 <----------------------------------+ max inflight = 0 |
| +---------+----------+ +--------------------+
| | 1. snapshot success
| | (next=snapshot.index + 1)
| | 2. snapshot failure
| | (no change)
| | 3. receives msgAppResp(rej=false&&index>lastsnap.index)
| | (match=m.index,next=match+1)
receives msgAppResp(rej=true)
(next=match+1)| |
| |
| |
| | receives msgAppResp(rej=false&&index>match)
| | (match=m.index,next=match+1)
| |
| |
| |
| +---------v----------+
| | replicate |
+---+ max inflight = n |
+--------------------+
```

When in `probe` state, leader sends at most one `replication message` per heartbeat interval. The leader sends `replication message` slowly and probing the actual progress of the follower. A `msgHeartbeatResp` or a `msgAppResp` with reject might trigger the sending of the next `replication message`.

When in `replicate` state, leader sends `replication message`, then optimistically increases `next` to the latest entry sent. This is an optimized state for fast replicating log entries to the follower.
Expand Down

0 comments on commit 42ecf74

Please sign in to comment.