diff --git a/server/etcdserver/server.go b/server/etcdserver/server.go index 4b40e32bada2..9cba4bc8c7df 100644 --- a/server/etcdserver/server.go +++ b/server/etcdserver/server.go @@ -858,8 +858,20 @@ func (s *EtcdServer) run() { } func (s *EtcdServer) revokeExpiredLeases(leases []*lease.Lease) { + lg := s.Logger() + newLeaderId := s.raftStatus().Lead + // This can only mitigate the issue. This can't completely resolve + // https://github.com/etcd-io/etcd/issues/15247. Because the leases + // may be wrongly revoked by the new leader. Refer to the document in + // https://github.com/etcd-io/etcd/issues/15247#issuecomment-1777862093. + if newLeaderId != uint64(s.MemberId()) { + lg.Warn("Ignore old leader's leases revoking requests", + zap.Uint64("local-member-id", uint64(s.MemberId())), + zap.Uint64("new-lead", newLeaderId)) + return + } + s.GoAttach(func() { - lg := s.Logger() // Increases throughput of expired leases deletion process through parallelization c := make(chan struct{}, maxPendingRevokes) for _, curLease := range leases { @@ -868,7 +880,6 @@ func (s *EtcdServer) revokeExpiredLeases(leases []*lease.Lease) { case <-s.stopping: return } - f := func(lid int64) { s.GoAttach(func() { ctx := s.authStore.WithRoot(s.ctx)