MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / updateRaftProgress

Method updateRaftProgress

worker/draft.go:1174–1193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1172}
1173
1174func (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
1195func (n *node) checkpointAndClose(done chan struct{}) {
1196 slowTicker := time.Tick(time.Minute)

Callers 2

checkpointAndCloseMethod · 0.95
BlockingStopFunction · 0.80

Calls 7

calculateSnapshotMethod · 0.95
OracleFunction · 0.92
MinPendingStartTsMethod · 0.80
InfofMethod · 0.80
UintMethod · 0.45
SetUintMethod · 0.45
GetIndexMethod · 0.45

Tested by

no test coverage detected