Do not replace the connection pool for a db load balancing host unchanged by a service discovery update

Context: #472161 (comment 2136350790)

When a database load balancing host (identified by ip / port) is present in both the old and new service discovery lists, it still gets replaced during a service discovery update (see https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/database/load_balancing/service_discovery.rb#L146-146).

This has a few undesired effects:

  • It recreates the connection pool for that host unnecessarily.
  • It "resets" that host to online without a log message if the host was offline before, confusing log analysis.

Change the above code snippet to reuse host objects where the ip/port is unchanged.