pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pgbench: Fail cleanly when finding a COPY result state
Date: Fri, 03 Oct 2025 05:04:54 +0000
Message-ID: <E1v4XyQ-001CtK-0L@gemulon.postgresql.org> (raw)

pgbench: Fail cleanly when finding a COPY result state

Currently, pgbench aborts when a COPY response is received in
readCommandResponse().  However, as PQgetResult() returns an empty
result when there is no asynchronous result, through getCopyResult(),
the logic done at the end of readCommandResponse() for the error path
leads to an infinite loop.

This commit forcefully exits the COPY state with PQendcopy() before
moving to the error handler when fiding a COPY state, avoiding the
infinite loop.  The COPY protocol is not supported by pgbench anyway, as
an error is assumed in this case, so giving up is better than having the
tool be stuck forever.  pgbench was interruptible in this state.

A TAP test is added to check that an error happens if trying to use
COPY.

Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Discussion: https://postgr.es/m/CAO6_XqpHyF2m73ifV5a=5jhXxH2chk=XrgefY+eWWPe2Eft3=A@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/de6de069d9c6b432a5dfd98b0784ed7f60a793ce

Modified Files
--------------
src/bin/pgbench/pgbench.c                    | 14 ++++++++++++++
src/bin/pgbench/t/001_pgbench_with_server.pl | 11 +++++++++++
2 files changed, 25 insertions(+)



view thread (7+ messages)  latest in thread

Message-ID: <E1v4XyQ-001CtK-0L@gemulon.postgresql.org>
Permalink:  ../E1v4XyQ-001CtK-0L@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1v4XyQ-001CtK-0L@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: pgbench: Fail cleanly when finding a COPY result state
  In-Reply-To: <E1v4XyQ-001CtK-0L@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