diff --git a/client/pd_service_discovery.go b/client/pd_service_discovery.go index 76feb887963..372f6e3edd9 100644 --- a/client/pd_service_discovery.go +++ b/client/pd_service_discovery.go @@ -1022,7 +1022,9 @@ func (c *pdServiceDiscovery) switchLeader(url string) (change bool, err error) { c.leader.Store(leaderClient) // Run callbacks if c.tsoGlobalAllocLeaderUpdatedCb != nil { - return change, c.tsoGlobalAllocLeaderUpdatedCb(url) + if err := c.tsoGlobalAllocLeaderUpdatedCb(url); err != nil { + return change, err + } } for _, cb := range c.leaderSwitchedCbs { cb()