Re: libpq support for NegotiateProtocolVersion

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Jacob Champion <jchampion(at)timescale(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq support for NegotiateProtocolVersion
Date: 2022-11-13 09:21:35
Message-ID: dfbfefe4-2cdd-7d6b-1365-e61d073d9833@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11.11.22 23:28, Jacob Champion wrote:
> Consider the case where the server sends a
> NegotiateProtocolVersion with a reasonable length, but then runs over
> its own message (either by sending an unterminated string as one of the
> extension names, or by sending a huge extension number). When I test
> that against a client on my machine, it churns CPU and memory waiting
> for the end of a message that will never come, even though it had
> already decided that the maximum length of the message should have been
> less than 2K.
>
> Put another way, why do we loop around and poll for more data when we
> hit the end of the connection buffer, if we've already checked at this
> point that we should have the entire message buffered locally?

Isn't that the same behavior for other message types? I don't see
anything in the handling of the early 'E' and 'R' messages that would
handle this. If we want to address this, maybe this should be handled
in the polling loop before we pass off the input buffer to the
per-message-type handlers.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2022-11-13 09:26:43 Re: refactor ownercheck and aclcheck functions
Previous Message Julien Rouhaud 2022-11-13 08:58:38 Re: proposal: possibility to read dumped table's name from file