Re: libpq compression

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Даниил Захлыстов <usernamedt(at)yandex-team(dot)ru>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: libpq compression
Date: 2020-10-28 16:25:34
Message-ID: 26003e29-5f01-ff42-0859-9d6f69a55148@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28.10.2020 17:57, Даниил Захлыстов wrote:
> Hi, thanks for the patch!
> I’ve made a quick review and found one issue.
> If the backend sends a CompressionAck message followed by some already
> compressed message (for example, AuthenticationOk), then there is a
> chance that pqReadData() will read both messages into the read buffer
> at once. In this case, the CompressionAck message will be read
> normally, but the client will fail to recognize the next message (for
> example, AuthenticationOk) since it came in a compressed form but was
> incorrectly read as a regular message. So the client would not be able
> to recognize the second message and will crash.
> Example of a successful launch (added some debug output):
> usernamedt-osx: ~ usernamedt $ psql -d "host = x.x.x.x port = 6432
> dbname = testdb user = testuser compression = 1"
> NUM_READ: 6 (pqReadData read CompressionAck (6 bytes) and nothing more)
> pqReadData RC: 1
> NUM_READ: 346
> pqReadData RC: 1
> psql (14devel)
> Type "help" for help.
> testdb => // OK
> Example of a failed launch:
> usernamedt-osx: ~ usernamedt $ psql -d "host = x.x.x.x port = 6432
> dbname = testdb user = testuser compression = 1"
> NUM_READ: 24 (pqReadData read CompressionAck (6 bytes) and compressed
> AuthenticationOk (18 bytes) came after it)
> pqReadData RC: 1
> psql: error: could not connect to server: expected authentication
> request from server, but received x // FAIL

Thank you for reporting the problem.
Fix is attached.

--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
libpq-compression-20.patch text/x-patch 43.0 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-10-28 16:25:41 Re: duplicate function oid symbols
Previous Message Bruce Momjian 2020-10-28 16:24:47 Re: Internal key management system