Skip to content

Commit

Permalink
cluster: fix tso fallback when pd leader switch
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Nov 7, 2024
1 parent b27f021 commit 403ae9e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (c *RaftCluster) startTSOJobsIfNeeded() error {
log.Error("failed to get global TSO allocator", errs.ZapError(err))
return err
}
if !allocator.IsInitialize() {
if !allocator.IsInitialize() && c.IsRunning() {
log.Info("initializing the global TSO allocator")
if err := allocator.Initialize(0); err != nil {
log.Error("failed to initialize the global TSO allocator", errs.ZapError(err))
Expand All @@ -487,7 +487,8 @@ func (c *RaftCluster) stopTSOJobsIfNeeded() error {
log.Error("failed to get global TSO allocator", errs.ZapError(err))
return err
}
if allocator.IsInitialize() {
if allocator.IsInitialize() && c.IsRunning() {
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 403ae9e

Please sign in to comment.