pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: libpq: Fix sending queries in pipeline aborted state
Date: Fri, 09 Jul 2021 20:11:22 +0000
Message-ID: <E1m1wqI-0001q1-MQ@gemulon.postgresql.org> (raw)

libpq: Fix sending queries in pipeline aborted state

When sending queries in pipeline mode, we were careless about leaving
the connection in the right state so that PQgetResult would behave
correctly; trying to read further results after sending a query after
having read a result with an error would sometimes hang.  Fix by
ensuring internal libpq state is changed properly.  All the state
changes were being done by the callers of pqAppendCmdQueueEntry(); it
would have become too repetitious to have this logic in each of them, so
instead put it all in that function and relieve callers of the
responsibility.

Add a test to verify this case.  Without the code fix, this new test
hangs sometimes.

Also, document that PQisBusy() would return false when no queries are
pending result.  This is not intuitively obvious, and NULL would be
obtained by calling PQgetResult() at that point, which is confusing.
Wording by Boris Kolpackov.

In passing, fix bogus use of "false" to mean "0", per Ranier Vilela.

Backpatch to 14.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reported-by: Boris Kolpackov <boris@codesynthesis.com>
Discussion: https://postgr.es/m/boris.20210624103805@codesynthesis.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1beaa654da61ee66857a3c5125682b629f62fdf9

Modified Files
--------------
doc/src/sgml/libpq.sgml                          |   5 +-
src/interfaces/libpq/fe-exec.c                   |  57 ++++--
src/test/modules/libpq_pipeline/libpq_pipeline.c | 226 +++++++++++++++++++++++
3 files changed, 274 insertions(+), 14 deletions(-)



view thread (2+ messages)

Message-ID: <E1m1wqI-0001q1-MQ@gemulon.postgresql.org>
Permalink:  ../E1m1wqI-0001q1-MQ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1m1wqI-0001q1-MQ@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: libpq: Fix sending queries in pipeline aborted state
  In-Reply-To: <E1m1wqI-0001q1-MQ@gemulon.postgresql.org>
  References: <E1m1wqI-0001q1-MQ@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox