Move the local variable cps into the loop so that it will not continue to schedule checkpoints after it steps down the leader

This commit is contained in:
ahrtr 2022-05-27 16:42:16 +08:00
parent ce77d83ee6
commit 1d482bfc08

View File

@ -646,10 +646,10 @@ func (le *lessor) revokeExpiredLeases() {
// checkpointScheduledLeases finds all scheduled lease checkpoints that are due and
// submits them to the checkpointer to persist them to the consensus log.
func (le *lessor) checkpointScheduledLeases() {
var cps []*pb.LeaseCheckpoint
// rate limit
for i := 0; i < leaseCheckpointRate/2; i++ {
var cps []*pb.LeaseCheckpoint
le.mu.Lock()
if le.isPrimary() {
cps = le.findDueScheduledCheckpoints(maxLeaseCheckpointBatchSize)