Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc781449

Browse files
NRG: Log when all servers decide to restart WAL
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
1 parent3624b16 commitc781449

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

‎server/raft.go‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3324,7 +3324,7 @@ func (n *raft) runAsCandidate() {
33243324
n.RLock()
33253325
nterm:=n.term
33263326
csz:=n.csz
3327-
repairing,initializing:=n.repairing,n.initializing
3327+
repairing,initializing,pindex,group:=n.repairing,n.initializing,n.pindex,n.group
33283328
n.RUnlock()
33293329

33303330
ifvresp.granted&&nterm==vresp.term {
@@ -3346,7 +3346,20 @@ func (n *raft) runAsCandidate() {
33463346
// Become LEADER if we've got voted in by ALL servers.
33473347
// We couldn't get quorum based on just our normal votes.
33483348
// But, we have heard from the full cluster, and some servers came up empty.
3349-
// We know for sure we have the most up-to-date log.
3349+
// We know for sure we have the most up-to-date log, but that log could also be empty.
3350+
ifgroup==defaultMetaGroupName||initializing||!repairing {
3351+
n.warn("Self got voted leader by all servers, restarting WAL with %d entries",pindex)
3352+
}else {
3353+
// If we are here, this means all logs required reparation (so none were complete),
3354+
// and we were the one with the most up-to-date log. We have either lost "all" or "some" data,
3355+
// but instead of halting, we prefer to become available again. All servers will agree on the
3356+
// new state of the log.
3357+
desc:="the log was fully lost"
3358+
ifpindex>0 {
3359+
desc="the log was partially reset"
3360+
}
3361+
n.warn("Self got voted leader by all servers, restarting WAL with %d entries, %s",pindex,desc)
3362+
}
33503363
n.switchToLeader()
33513364
return
33523365
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp