Skip to content

Commit

Permalink
Close idle conns when closing consul topo
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed May 18, 2024
1 parent 951f273 commit ccc65da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions go/vt/topo/consultopo/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,13 @@ func parseConsulLockSessionChecks(s string) []string {
}

// Close implements topo.Server.Close.
// It will nil out the global and cells fields, so any attempt to
// re-use this server will panic.
// It will close idle http connections and nil out the global
// and cells fields, so any attempt to re-use this server
// will panic.
func (s *Server) Close() {
if consulConfig.Transport != nil {
consulConfig.Transport.CloseIdleConnections()
}
s.client = nil
s.kv = nil
s.mu.Lock()
Expand Down
1 change: 1 addition & 0 deletions go/vt/vttest/topoctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (ctl *Topoctl) Setup() error {
if err != nil {
return err
}
defer topoServer.Close()

log.Infof("Creating cells if they don't exist in the provided topo server %s %s %s", ctl.TopoImplementation, ctl.TopoGlobalServerAddress, ctl.TopoGlobalRoot)
// Create cells if it doesn't exist to be idempotent. Should work when we share the same topo server across multiple local clusters.
Expand Down

0 comments on commit ccc65da

Please sign in to comment.