Re: SSL negotiation error on massive connect/disconnect - Mailing list pgsql-hackers

From Maxim Orlov
Subject Re: SSL negotiation error on massive connect/disconnect
Date
Msg-id 7b6af2fd09cb06181fa61038dedc7008@postgrespro.ru
Whole thread Raw
List 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@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

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: psql - add SHOW_ALL_RESULTS option
Next
From: Magnus Hagander
Date:
Subject: Re: Small typo in guc.c