Re: [EXTERNAL] Support load balancing in libpq
Jelte Fennema-Nio <postgres@jeltef.nl>
From: Jelte Fennema <postgres@jeltef.nl>
To: Aleksander Alekseev <aleksander@timescale.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>,
Daniel Gustafsson <daniel@yesql.se>, "Gregory Stark (as CFM)" <stark.cfm@gmail.com>,
Andrey Borodin <amborodin86@gmail.com>, Jacob Champion <jchampion@timescale.com>, Maxim Orlov <orlovmg@gmail.com>, Jelte Fennema <Jelte.Fennema@microsoft.com>, Michael Banck <mbanck@gmx.net>, Andres Freund <andres@anarazel.de>
Date: 2023-03-27T14:51:56Z
Lists: pgsql-hackers
> > ``` > > if (conn->addr == NULL && conn->naddr != 0) > > ``` Afaict this is not necessary, since getaddrinfo already returns an error if the host could not be resolved to any addresses. A quick test gives me this error: error: could not translate host name "doesnotexist" to address: Name or service not known > > ``` > + } > + else > + conn->load_balance_type = LOAD_BALANCE_DISABLE; > ``` > > The else branch is never executed. I don't think that line is coverable then. There's definitely places in the test suite where load_balance_hosts is not explicitly set. But even in those cases I guess the argument parsing logic will use DefaultLoadBalanceHosts instead of NULL as a value for conn->load_balance_type. > Strangely enough the body of the for loop is never executed either. > Apparently only one address is used and there is nothing to shuffle? > > Here is the exact command I used to build the code coverage report: I guess you didn't set up the hostnames in /etc/hosts as described in 004_load_balance_dns.pl. Then it's expected that the loop body isn't covered. As discussed upthread, running this test manually is much more cumbersome than is desirable, but it's still better than not having the test at all, because it is run in CI.
Commits
-
Fix pointer cast for seed calculation on 32-bit systems
- 2fe7a6df94e6 16.0 landed
-
Copy and store addrinfo in libpq-owned private memory
- 44d85ba5a336 16.0 landed
-
libpq: Use modern socket flags, if available.
- bfc9497ece01 16.0 cited