()
| 1172 | } |
| 1173 | |
| 1174 | func (n *node) updateRaftProgress() error { |
| 1175 | // Both leader and followers can independently update their Raft progress. We don't store |
| 1176 | // this in Raft WAL. Instead, this is used to just skip over log records that this Alpha |
| 1177 | // has already applied, to speed up things on a restart. |
| 1178 | // |
| 1179 | // Let's check what we already have. And only update if the new snap.Index is ahead of the last |
| 1180 | // stored applied. |
| 1181 | applied := n.Store.Uint(raftwal.CheckpointIndex) |
| 1182 | |
| 1183 | snap, err := n.calculateSnapshot(applied, n.Applied.DoneUntil(), |
| 1184 | posting.Oracle().MinPendingStartTs()) |
| 1185 | if err != nil || snap == nil || snap.Index <= applied { |
| 1186 | return err |
| 1187 | } |
| 1188 | atomic.StoreUint64(&n.checkpointTs, snap.ReadTs) |
| 1189 | |
| 1190 | n.Store.SetUint(raftwal.CheckpointIndex, snap.GetIndex()) |
| 1191 | glog.V(2).Infof("[%#x] Set Raft progress to index: %d, ts: %d.", n.Id, snap.Index, snap.ReadTs) |
| 1192 | return nil |
| 1193 | } |
| 1194 | |
| 1195 | func (n *node) checkpointAndClose(done chan struct{}) { |
| 1196 | slowTicker := time.Tick(time.Minute) |
no test coverage detected