Skip to content

Commit

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

Signed-off-by: lhy1024 <admin@liudos.us>
  • Loading branch information
lhy1024 authored Nov 7, 2024
1 parent b27f021 commit b19cec5
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 @@ -460,7 +460,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 @@ -488,6 +495,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 b19cec5

Please sign in to comment.