Re: BUG #17948: libpq seems to misbehave in a pipelining corner case - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #17948: libpq seems to misbehave in a pipelining corner case
Date
Msg-id 202312011420.zmxtoxtvu6ip@alvherre.pgsql
Whole thread Raw
In response to BUG #17948: libpq seems to misbehave in a pipelining corner case  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #17948: libpq seems to misbehave in a pipelining corner case
List pgsql-bugs
On 2023-Aug-05, Трофимов Иван wrote:

>    We've managed to reproduce client <-> server de-synchronization triggered
>    by this, which we are seeing in production.
>    Libpq considers '< 2TDCEZ' a sufficient response to '> BDESS', when
>    according to specification one more 'Z' is expected.
>     
>    A bit more context and a MRE:
>    https://github.com/itrofimow/libpq_protocol_desync

Does this patch fix the problems?  I think the sync loss is because
we're consuming elements from the command queue even when we shouldn't,
because we don't know for an ERROR whether we should do so or not.  What
this patch does is a bit of a hack, I think, but it does solve your test
case (and it doesn't break anything else in the tree) AFAICS.  I may
have to play some more with it before gaining confidence, though.

Thanks

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Hay dos momentos en la vida de un hombre en los que no debería
especular: cuando puede permitírselo y cuando no puede" (Mark Twain)

Attachment

pgsql-bugs by date:

Previous
From: Richard Guo
Date:
Subject: Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower
Next
From: PG Bug reporting form
Date:
Subject: BUG #18221: Unexpected Query Result