fix: improve multihost connection for preferSlave case (verify expired hosts before connecting to cached master) (#844)
The notable behavior change is related with targetServerType=preferSlave.
In that case, it requires to check all the possible slaves first to find the right server.
The state of some servers might be expired due to hostRecheckSeconds,
so pgjdbc should try connecting to all the "known slaves"
and "expired" servers in attempt to find a slave among them, and only then
it should try connecting to master.
That logic was not there, and preferSlave could easily connect to master even
at times when a slave was available.
Note: hostRecheckSeconds is still in place (default 10 seconds), and pgdjbc
trusts that status.
However, there's an exception: in case no servers match the criteria (e.g.
all the servers are marked with "can't connect" in cache), then pgjdbc
would still try connecting to all the hosts in the connection URL in order.