Skip to content

Commit

Permalink
mcs, tso: delete the tso ms discovery when switching away from API mo…
Browse files Browse the repository at this point in the history
…de. (#6544)

close #6543

When switching from the PD mode to the API mode, the old tso microservice discovery isn't needed anymore,
and all resources can be released to avoid noisy error logs when the component trying to discover
the non-existent tso microservice.

Signed-off-by: Bin Shi <[email protected]>
  • Loading branch information
binshi-bing committed Jun 1, 2023
1 parent b640a3c commit 672f4dc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,13 +621,13 @@ func (c *client) setServiceMode(newMode pdpb.ServiceMode) {
oldTSOClient.Close()
// Replace the old TSO service discovery if needed.
oldTSOSvcDiscovery := c.tsoSvcDiscovery
if newTSOSvcDiscovery != nil {
c.tsoSvcDiscovery = newTSOSvcDiscovery
// Close the old TSO service discovery safely after both the old client
// and service discovery are replaced.
if oldTSOSvcDiscovery != nil {
oldTSOSvcDiscovery.Close()
}
// If newTSOSvcDiscovery is nil, that's expected, as it means we are switching to PD service mode and
// no tso microservice discovery is needed.
c.tsoSvcDiscovery = newTSOSvcDiscovery
// Close the old TSO service discovery safely after both the old client and service discovery are replaced.
if oldTSOSvcDiscovery != nil {
// We are switching from API service mode to PD service mode, so delete the old tso microservice discovery.
oldTSOSvcDiscovery.Close()
}
oldMode := c.serviceMode
c.serviceMode = newMode
Expand Down

0 comments on commit 672f4dc

Please sign in to comment.