Skip to content

Commit

Permalink
cluster: fix tso fallback when pd leader switch (tikv#8783) (tikv#8784)
Browse files Browse the repository at this point in the history
close tikv#8781

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: lhy1024 <admin@liudos.us>
  • Loading branch information
ti-chi-bot and lhy1024 authored Nov 7, 2024
1 parent 649393a commit 051907b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,14 @@ func (c *RaftCluster) runServiceCheckJob() {
case <-schedulingTicker.C:
c.checkSchedulingService()
case <-tsoTicker.C:
c.checkTSOService()
// ensure raft cluster is running
// avoid unexpected startTSOJobsIfNeeded when raft cluster is stopping
// ref: https://github.com/tikv/pd/issues/8781
c.RLock()
if c.running {
c.checkTSOService()
}
c.RUnlock()
}
}
}
Expand Down Expand Up @@ -489,6 +496,7 @@ func (c *RaftCluster) stopTSOJobsIfNeeded() error {
return err
}
if allocator.IsInitialize() {
log.Info("closing the global TSO allocator")
c.tsoAllocator.ResetAllocatorGroup(tso.GlobalDCLocation, true)
failpoint.Inject("updateAfterResetTSO", func() {
allocator, _ := c.tsoAllocator.GetAllocator(tso.GlobalDCLocation)
Expand Down

0 comments on commit 051907b

Please sign in to comment.