Re: [EXTERNAL] Support load balancing in libpq

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Jelte Fennema <postgres(at)jeltef(dot)nl>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, Andrey Borodin <amborodin86(at)gmail(dot)com>, Jacob Champion <jchampion(at)timescale(dot)com>, Maxim Orlov <orlovmg(at)gmail(dot)com>, Jelte Fennema <Jelte(dot)Fennema(at)microsoft(dot)com>, Michael Banck <mbanck(at)gmx(dot)net>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: [EXTERNAL] Support load balancing in libpq
Date: 2023-03-27 12:01:36
Message-ID: CAJ7c6TO8Dg3ZvpPpP9G5_gmnR8KmzPpJyBwsMx9Zaky84=zS6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> > ▶ 6/6 - received at least one connection on node1 OK
> > ▶ 6/6 - received at least one connection on node2 OK
> > ▶ 6/6 - received at least one connection on node3 OK
> > ▶ 6/6 - received 50 connections across all nodes OK
>
> Good point.
>
> > Finally, I changed a few small typos in your updated commit message
> > (some of which originated from my earlier commit messages)
>
> +1

Hi,

> I would like to see this wrapped up in the current CF, what do you think about
> the attached?

In v15-0001:

```
+ conn->addr = calloc(conn->naddr, sizeof(AddrInfo));
+ if (conn->addr == NULL)
+ {
+ libpq_append_conn_error(conn, "out of memory");
+ return 1;
+ }
```

According to the man pages, in a corner case when naddr is 0 calloc
can return NULL which will not indicate an error.

So I think it should be:

```
if (conn->addr == NULL && conn->naddr != 0)
```

Other than that v15 looked very good. It was checked on Linux and
MacOS including running it under sanitizer.

I will take a look at v16 now.

--
Best regards,
Aleksander Alekseev

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dagfinn Ilmari Mannsåker 2023-03-27 12:04:03 Re: MacOS: xsltproc fails with "warning: failed to load external entity"
Previous Message Daniel Gustafsson 2023-03-27 11:57:46 Re: [EXTERNAL] Support load balancing in libpq