Re: [EXTERNAL] Support load balancing in libpq - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: [EXTERNAL] Support load balancing in libpq
Date
Msg-id CAJ7c6TO8Dg3ZvpPpP9G5_gmnR8KmzPpJyBwsMx9Zaky84=zS6Q@mail.gmail.com
Whole thread Raw
In response to Re: [EXTERNAL] Support load balancing in libpq  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: [EXTERNAL] Support load balancing in libpq  (Aleksander Alekseev <aleksander@timescale.com>)
List 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



pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: [EXTERNAL] Support load balancing in libpq
Next
From: Dagfinn Ilmari Mannsåker
Date:
Subject: Re: MacOS: xsltproc fails with "warning: failed to load external entity"