Re: Pipeline mode and PQpipelineSync()

From: Alvaro Herrera <alvaro(dot)herrera(at)2ndquadrant(dot)com>
To: Boris Kolpackov <boris(at)codesynthesis(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Michael Paquier <michael(at)paquier(dot)xyz>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Peter Geoghegan <pg(at)bowt(dot)ie>
Subject: Re: Pipeline mode and PQpipelineSync()
Date: 2021-07-08 17:29:23
Message-ID: 202107081729.osyyji4ewzjk@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-Jul-08, Boris Kolpackov wrote:

> Alvaro Herrera <alvaro(dot)herrera(at)2ndquadrant(dot)com> writes:

> > That seems a fair complaint, but I think PQisBusy is doing the right
> > thing per its charter. It is documented as "would PQgetResult block?"
> > and it is returning correctly that PQgetResult would not block in that
> > situation, because no queries are pending.
>
> Well, that's one way to view it. But in this case one can say that
> the entire pipeline is still "busy" since we haven't seen the
> PQpipelineSync() call. So maybe we could change the charter only
> for this special situation (that is, inside the pipeline)?

To be honest, I am hesitant to changing the charter in that way; I fear
it may have consequences I don't foresee. I think the workaround is not
*that* bad. On the other hand, since we explicitly made PQpipelineSync
not mandatory, it would be confusing to say that PQisBusy requires
PQpipelineSync to work properly.

> But I agree, it may not be worth the trouble and a note in the
> documentation may be an acceptable "solution".

I'm having a bit of trouble documenting this. I modified the paragraph in the
pipeline mode docs to read:

<para>
<function>PQisBusy</function>, <function>PQconsumeInput</function>, etc
operate as normal when processing pipeline results. Note that if no
queries are pending receipt of the corresponding results,
<function>PQisBusy</function> returns 0.
</para>

This seems a bit silly/obvious to me, but it may be enlightening to
people writing apps to use pipeline mode. Do you find this sufficient?
(I tried to add something to the PQisBusy description, but it sounded
sillier.)

> I am happy to go either way, just let me know what it will be. And
> also if the latest patch to libpq that you have shared[1] is still
> necessary.
>
> [1] https://www.postgresql.org/message-id/202107061747.tlss7f2somqf%40alvherre.pgsql

Yes, this patch (or some version thereof) is still needed. I didn't
test the modified version of your program without it, but my repro
definitely misbehaved without it.

--
Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2021-07-08 17:33:28 Re: "debug_invalidate_system_caches_always" is too long
Previous Message Robert Haas 2021-07-08 17:29:04 Re: enable_resultcache confusion