Skip to content

Commit

Permalink
fix the data race problem
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Jun 15, 2021
1 parent 69209e0 commit 52711fb
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 @@ -1239,6 +1239,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 @@ -1250,10 +1255,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 52711fb

Please sign in to comment.