Skip to content

Commit c0dc6a0

Browse files
authored
Add logging on active node when sending a snapshot to a follower (#636)
* Add a log line on active node when sending snapshot to a follower * Add snap ID and peer ID to relevant log lines in sendLatestSnapshot; fix - use peer.ID instead of peer as a value in log line * Add an INFO log line when opening a snapshot in sendLatestSnapshot
1 parent 8f99c15 commit c0dc6a0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ _testmain.go
2121

2222
*.exe
2323
*.test
24+
25+
# Goland IDE
26+
.idea

replication.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ func (r *Raft) sendLatestSnapshot(s *followerReplication) (bool, error) {
311311

312312
// Open the most recent snapshot
313313
snapID := snapshots[0].ID
314+
r.logger.Info("opening snapshot", "id", snapID)
314315
meta, snapshot, err := r.snapshots.Open(snapID)
315316
if err != nil {
316317
r.logger.Error("failed to open snapshot", "id", snapID, "error", err)
@@ -337,11 +338,12 @@ func (r *Raft) sendLatestSnapshot(s *followerReplication) (bool, error) {
337338
peer := s.peer
338339
s.peerLock.RUnlock()
339340

341+
r.logger.Info("installing snapshot on", "peer", peer.ID, "id", snapID, "size", req.Size)
340342
// Make the call
341343
start := time.Now()
342344
var resp InstallSnapshotResponse
343345
if err := r.trans.InstallSnapshot(peer.ID, peer.Address, &req, &resp, snapshot); err != nil {
344-
r.logger.Error("failed to install snapshot", "id", snapID, "error", err)
346+
r.logger.Error("failed to install snapshot", "peer", peer.ID, "id", snapID, "error", err)
345347
s.failures++
346348
return false, err
347349
}
@@ -375,7 +377,7 @@ func (r *Raft) sendLatestSnapshot(s *followerReplication) (bool, error) {
375377
s.notifyAll(true)
376378
} else {
377379
s.failures++
378-
r.logger.Warn("installSnapshot rejected to", "peer", peer)
380+
r.logger.Warn("installSnapshot rejected to", "peer", peer.ID, "id", snapID)
379381
}
380382
return false, nil
381383
}

0 commit comments

Comments
 (0)