Re: BUG #17948: libpq seems to misbehave in a pipelining corner case

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Ivan Trofimov <i(dot)trofimow(at)yandex(dot)ru>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17948: libpq seems to misbehave in a pipelining corner case
Date: 2023-12-04 18:47:51
Message-ID: 202312041847.iur3zphjejur@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2023-Dec-02, Ivan Trofimov wrote:

> Thank you for looking into this, much appreciated.
>
> Yes, I can confirm that the patch fixes both the busy-loop and
> client<->server desynchronization problem for me.

Great, thanks for the confirmation.

Mulling it over while writing better comments for it, I realized that it
could still be somewhat brittle, and it's also confusing that part of
the logic is in PQgetResult and the rest in pqCommandQueueAdvance; so I
moved it all to the latter, which also lets me document it more clearly
in the comments. I addressed the brittleness by changing what to test:
instead of just "it's an error, then do nothing if the queue has a
SYNC", we can verify that we actually have a matching SYNC in both
places. This seems much better.

Patch v2 attached. I'll be pushing this to 14+ tomorrow, unless
something ugly comes up.

Thanks for reporting this problem!

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"El hombre nunca sabe de lo que es capaz hasta que lo intenta" (C. Dickens)

Attachment Content-Type Size
v2-0001-Fix-handling-of-errors-in-libpq-pipelines.patch text/x-diff 5.6 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2023-12-05 02:35:03 Re: BUG #18187: Unexpected error: "variable not found in subplan target lists" triggered by JOIN
Previous Message Tom Lane 2023-12-04 14:53:22 Re: BUG #18225: chdb's s3 table function crashes postgresql with plpython3