Re: Using PQexecQuery in pipeline mode produces unexpected Close messages

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: daniele(dot)varrazzo(at)gmail(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Using PQexecQuery in pipeline mode produces unexpected Close messages
Date: 2022-06-15 18:26:33
Message-ID: 20220615182633.ztcoloh7xbicggot@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 2022-Jun-10, Kyotaro Horiguchi wrote:

> (Moved to -hackers)
>
> At Wed, 8 Jun 2022 17:08:47 +0200, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote in
> > What that Close message is doing is closing the unnamed portal, which
> > is otherwise closed implicitly when the next one is opened. That's how
> > single-query mode works: if you run a single portal, it'll be kept open.
> >
> > I believe that the right fix is to not send that Close message in
> > PQsendQuery.
>
> Agreed. At least Close message in that context is useless and
> PQsendQueryGuts doesn't send it. And removes the Close message surely
> fixes the issue.

So, git archaeology led me to this thread
https://postgr.es/m/202106072107.d4i55hdscxqj@alvherre.pgsql
which is why we added that message in the first place.

I was about to push the attached patch (a merged version of Kyotaro's
and mine), but now I'm wondering if that's the right approach.

Alternatives:

- Have the client not complain if it gets CloseComplete in idle state.
(After all, it's a pretty useless message, since we already do nothing
with it if we get it in BUSY state.)

- Have the server not send CloseComplete at all in the cases where
the client is not expecting it. Not sure how this would be
implemented.

- Other ideas?

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"That sort of implies that there are Emacs keystrokes which aren't obscure.
I've been using it daily for 2 years now and have yet to discover any key
sequence which makes any sense." (Paul Thomas)

Attachment Content-Type Size
v2-0001-PQsendQuery-Don-t-send-Close-in-pipeline-mode.patch text/x-diff 6.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-06-15 18:56:42 Re: Using PQexecQuery in pipeline mode produces unexpected Close messages
Previous Message Nathan Bossart 2022-06-15 17:35:08 Re: Extension pg_trgm, permissions and pg_dump order

Browse pgsql-hackers by date

  From Date Subject
Next Message Imseih (AWS), Sami 2022-06-15 18:45:38 [PROPOSAL] Detecting plan changes with plan_id in pg_stat_activity
Previous Message Tom Lane 2022-06-15 18:02:03 Re: "buffer too small" or "path too long"?