@@ -284,22 +284,26 @@ func GetSubstrate() (substrate.Manager, error) {
284284 if err != nil {
285285 return nil , errors .Wrap (err , "failed to get boot environment" )
286286 }
287+ updatedSubURLs := env .SubstrateURL
287288
288289 slices .Sort (subURLs )
289- slices .Sort (env . SubstrateURL )
290+ slices .Sort (updatedSubURLs )
290291
291292 // if substrate url changed then update subURLs and update pool with new manager only if the old connection is broken
292- if ! slices .Equal (subURLs , env . SubstrateURL ) {
293+ if ! slices .Equal (subURLs , updatedSubURLs ) {
293294 // before attempting to update the manager check if pool variable maintain a healthy connection
294295 // pool.Row() checks the health of the connection and if all the urls used in pool are down, then it will return error
295- cl , _ , err := pool . Raw ()
296- // if the old manager is broken, then we should update the manager
297- if err ! = nil {
298- log . Debug (). Strs ( "substrate_urls" , env . SubstrateURL ). Msg ( "updating to sub manager with url" )
299- subURLs = env . SubstrateURL
300- pool = substrate . NewManager ( env . SubstrateURL ... )
296+ if pool != nil {
297+ cl , _ , err := pool . Raw ()
298+ if err = = nil {
299+ cl . Client . Close ( )
300+ return pool , nil
301+ }
301302 }
302- cl .Client .Close ()
303+
304+ log .Debug ().Strs ("substrate_urls" , updatedSubURLs ).Msg ("updating to sub manager with url" )
305+ pool = substrate .NewManager (env .SubstrateURL ... )
306+ subURLs = updatedSubURLs
303307 }
304308
305309 // poolOnce.Do(func() {
0 commit comments