Skip to content

Commit

Permalink
reslove conflict
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <nolouch@gmail.com>
  • Loading branch information
Mini256 authored and nolouch committed Jul 5, 2021
1 parent ceac99b commit e298cd9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 38 deletions.
38 changes: 6 additions & 32 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,8 +1128,11 @@ func (s *Server) campaignLeader() {
// 2. load region could be slow. Based on lease we can recover TSO service faster.

ctx, cancel := context.WithCancel(s.serverLoopCtx)
<<<<<<< HEAD
defer cancel()
var resetLeaderOnce sync.Once
defer resetLeaderOnce.Do(func() {
cancel()
})

go lease.KeepAlive(ctx)
s.SetLease(lease)
defer s.SetLease(nil)
Expand All @@ -1141,29 +1144,6 @@ func (s *Server) campaignLeader() {
return
}
defer s.tso.ResetTimestamp()
=======
var resetLeaderOnce sync.Once
defer resetLeaderOnce.Do(func() {
cancel()
s.member.ResetLeader()
})

// maintain the PD leadership, after this, TSO can be service.
go s.member.KeepLeader(ctx)
log.Info("campaign pd leader ok", zap.String("campaign-pd-leader-name", s.Name()))

alllocator, err := s.tsoAllocatorManager.GetAllocator(tso.GlobalDCLocation)
if err != nil {
log.Error("failed to get the global TSO allocator", errs.ZapError(err))
return
}
log.Info("initializing the global TSO allocator")
if err := alllocator.Initialize(0); err != nil {
log.Error("failed to initialize the global TSO allocator", errs.ZapError(err))
return
}
defer s.tsoAllocatorManager.ResetAllocatorGroup(tso.GlobalDCLocation)
>>>>>>> 71b12e40a (server: make leader can lost lease as soon as possible (#3712))

err := s.reloadConfigFromKV()
if err != nil {
Expand All @@ -1187,18 +1167,12 @@ func (s *Server) campaignLeader() {
}
// EnableLeader to accept the remaining service, such as GetStore, GetRegion.
s.member.EnableLeader()
<<<<<<< HEAD
defer s.member.DisableLeader()
=======
// Check the cluster dc-location after the PD leader is elected.
go s.tsoAllocatorManager.ClusterDCLocationChecker()
defer resetLeaderOnce.Do(func() {
// as soon as cancel the leadership keepalive, then other member have chance
// to be new leader.
cancel()
s.member.ResetLeader()
s.member.DisableLeader()
})
>>>>>>> 71b12e40a (server: make leader can lost lease as soon as possible (#3712))

CheckPDVersion(s.persistOptions)
log.Info("PD cluster leader is ready to serve", zap.String("leader-name", s.Name()))
Expand Down
8 changes: 2 additions & 6 deletions tests/server/member/member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,7 @@ func (s *serverTestSuite) TestLeaderResign(c *C) {
c.Assert(leader3, Equals, leader1)
}

<<<<<<< HEAD
func (s *serverTestSuite) waitLeaderChange(c *C, cluster *tests.TestCluster, old string) string {
=======
func (s *memberTestSuite) TestLeaderResignWithBlock(c *C) {
func (s *serverTestSuite) TestLeaderResignWithBlock(c *C) {
cluster, err := tests.NewTestCluster(s.ctx, 3)
defer cluster.Destroy()
c.Assert(err, IsNil)
Expand All @@ -245,8 +242,7 @@ func (s *memberTestSuite) TestLeaderResignWithBlock(c *C) {
c.Assert(leader2, Not(Equals), leader1)
}

func (s *memberTestSuite) waitLeaderChange(c *C, cluster *tests.TestCluster, old string) string {
>>>>>>> 71b12e40a (server: make leader can lost lease as soon as possible (#3712))
func (s *serverTestSuite) waitLeaderChange(c *C, cluster *tests.TestCluster, old string) string {
var leader string
testutil.WaitUntil(c, func(c *C) bool {
leader = cluster.GetLeader()
Expand Down

0 comments on commit e298cd9

Please sign in to comment.