Skip to content

Commit

Permalink
[dnm] improved heuristics
Browse files Browse the repository at this point in the history
This results in 1-2 remaining Raft snapshots (down from many tens). In
these cases, the generation has already gone up from zero because the
range has split again.

Release note: None
  • Loading branch information
tbg committed Oct 27, 2018
1 parent 6489745 commit cd3a65d
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions pkg/storage/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -5108,13 +5108,27 @@ func (r *Replica) sendRaftMessage(ctx context.Context, msg raftpb.Message) {

// Raft-initiated snapshots are handled by the Raft snapshot queue.
if msg.Type == raftpb.MsgSnap {
r.withRaftGroup(false, func(rn *raft.RawNode) (bool, error) {
rn.ReportSnapshot(msg.To, raft.SnapshotFinish)
return false, nil
})
return // HACK
if _, err := r.store.raftSnapshotQueue.Add(r, raftSnapshotPriority); err != nil {
log.Errorf(ctx, "unable to add replica to Raft repair queue: %s", err)
r.mu.Lock()
desc := r.descRLocked()
raftStatus := r.raftStatusRLocked()
ticks := r.mu.ticks
r.mu.Unlock()

recentlyCreatedViaSplit := desc.IsInitialized() && (desc.Generation == nil || *desc.Generation == 0) &&
raftStatus != nil && raftStatus.Progress[msg.To].Match == 0 &&
ticks <= 15

if recentlyCreatedViaSplit {
r.withRaftGroup(false, func(rn *raft.RawNode) (bool, error) {
rn.ReportSnapshot(msg.To, raft.SnapshotFinish)
return false, nil
})
} else {
log.Warningf(ctx, "TSX snapshot for replicaID %d %+v with raftStatus %+v and %d ticks", msg.To, desc, raftStatus, ticks)
log.Warning(ctx, desc.IsInitialized(), desc.Generation != nil && *desc.Generation == 0, raftStatus != nil && raftStatus.Progress[msg.To].Match == 0, ticks <= 15)
if _, err := r.store.raftSnapshotQueue.Add(r, raftSnapshotPriority); err != nil {
log.Errorf(ctx, "unable to add replica to Raft repair queue: %s", err)
}
}
return
}
Expand Down

0 comments on commit cd3a65d

Please sign in to comment.