Re: SSL negotiation error on massive connect/disconnect

From: Maxim Orlov <m(dot)orlov(at)postgrespro(dot)ru>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SSL negotiation error on massive connect/disconnect
Date: 2021-04-09 10:56:05
Message-ID: 7b6af2fd09cb06181fa61038dedc7008@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-03-01 17:22, Maxim Orlov wrote:
> Hi!
>
> I have primary server on port 55942 and two standbys on 55943 and
> 55944. Then use connection string like
> "postgresql://127.0.0.1:55942,127.0.0.1:55943,127.0.0.1:55944/postgres"
> to connect to the servers via psql.
>
> Everything works perfectly no matter how many attempts to connect I do.
> But when I stop primary server, very rarely I do get an error
> "received invalid response to SSL negotiation" from psql. I got this
> error when I tried to make massive connects/disconnects test and it's
> unlikely to reproduce manually without thousands of connections
> sequentially with no intentional delay in between.
>
> The problem present only on Linux, MacOS works fine.
>
> As far as I understand this particular problem is because of
> postgresql gets "zero" (i.e. 0) byte in SSLok in
> PQconnectPoll(at)src/interfaces/libpq/fe-connect.c. This lead to select
> "else" branch with described error message. This may be fixed by
> handling zero byte as 'E' byte. But I'm not sure if it's good
> solution, since I don't know why fe-connect gets an zero byte at all.
>
> I consider it's worth to correct this. This error is rare but it's
> really odd to notice this unexpected and wrong behavior.
>
> ---
> Best regards,
> Maxim Orlov.

Correction. Previous patch was wrong. The proper one is here.

---
Best regards,
Maxim Orlov.

Attachment Content-Type Size
0001-WIP-2.patch text/x-diff 5.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2021-04-09 11:12:33 Re: Small typo in guc.c
Previous Message Michael Paquier 2021-04-09 10:51:25 Re: psql - add SHOW_ALL_RESULTS option