Skip to content

Commit

Permalink
server: fix the data race problem (#3772) (#3774)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
ti-chi-bot and rleungx committed Jun 25, 2021
1 parent 53b7a3e commit 08369e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,11 @@ func (s *Server) campaignLeader() {
return
}

if err := s.persistOptions.LoadTTLFromEtcd(s.ctx, s.client); err != nil {
log.Error("failed to load persistOptions from etcd", errs.ZapError(err))
return
}

if err := s.encryptionKeyManager.SetLeadership(s.member.GetLeadership()); err != nil {
log.Error("failed to initialize encryption", errs.ZapError(err))
return
Expand All @@ -1258,10 +1263,6 @@ func (s *Server) campaignLeader() {
return
}
defer s.stopRaftCluster()
if err := s.persistOptions.LoadTTLFromEtcd(s.ctx, s.client); err != nil {
log.Error("failed to load persistOptions from etcd", errs.ZapError(err))
return
}
if err := s.idAllocator.Rebase(); err != nil {
log.Error("failed to sync id from etcd", errs.ZapError(err))
return
Expand Down

0 comments on commit 08369e5

Please sign in to comment.