From 8aa57bbca5f9893f2d63c0fba7b82b2731d41fe0 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Mon, 9 Nov 2020 22:21:37 -0800 Subject: [PATCH 1/3] be more lenient on grace period --- consensus/leader.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/consensus/leader.go b/consensus/leader.go index fca20e08a..7a764c967 100644 --- a/consensus/leader.go +++ b/consensus/leader.go @@ -303,9 +303,15 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) { consensus.preCommitAndPropose(blockObj) } - consensus.getLogger().Info().Msg("[OnCommit] Starting Grace Period") go func(viewID uint64) { - time.Sleep(1000 * time.Millisecond) + waitTime := 1000 * time.Millisecond + maxWaitTime := time.Until(consensus.NextBlockDue) + if maxWaitTime > waitTime { + waitTime = maxWaitTime + } + consensus.getLogger().Info().Str("waitTime", waitTime.String()). + Msg("[OnCommit] Starting Grace Period") + time.Sleep(waitTime) logger.Info().Msg("[OnCommit] Commit Grace Period Ended") consensus.mutex.Lock() From a71d8f48f78d6ea2a258964179532f335d471898 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 10 Nov 2020 12:11:29 -0800 Subject: [PATCH 2/3] leave some time for finalCommit --- consensus/leader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/leader.go b/consensus/leader.go index 7a764c967..568694ce1 100644 --- a/consensus/leader.go +++ b/consensus/leader.go @@ -305,7 +305,7 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) { go func(viewID uint64) { waitTime := 1000 * time.Millisecond - maxWaitTime := time.Until(consensus.NextBlockDue) + maxWaitTime := time.Until(consensus.NextBlockDue) - 100*time.Millisecond if maxWaitTime > waitTime { waitTime = maxWaitTime } From 2cc6d17a6fc2b63000f89eb01c1578c29fe2da9c Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 10 Nov 2020 12:12:10 -0800 Subject: [PATCH 3/3] leave some time for finalCommit --- consensus/leader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/leader.go b/consensus/leader.go index 568694ce1..22313885a 100644 --- a/consensus/leader.go +++ b/consensus/leader.go @@ -305,7 +305,7 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) { go func(viewID uint64) { waitTime := 1000 * time.Millisecond - maxWaitTime := time.Until(consensus.NextBlockDue) - 100*time.Millisecond + maxWaitTime := time.Until(consensus.NextBlockDue) - 200*time.Millisecond if maxWaitTime > waitTime { waitTime = maxWaitTime }