pgsql: pgbench: Fix assertion failure with multiple \syncpipeline in pi

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pgbench: Fix assertion failure with multiple \syncpipeline in pi
Date: 2025-11-14 13:42:42
Message-ID: E1vJu4Y-006ZQl-1a@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pgbench: Fix assertion failure with multiple \syncpipeline in pipeline mode.

Previously, when pgbench ran a custom script that triggered retriable errors
(e.g., deadlocks) followed by multiple \syncpipeline commands in pipeline mode,
the following assertion failure could occur:

Assertion failed: (res == ((void*)0)), function discardUntilSync, file pgbench.c, line 3594.

The issue was that discardUntilSync() assumed a pipeline sync result
(PGRES_PIPELINE_SYNC) would always be followed by either another sync result
or NULL. This assumption was incorrect: when multiple sync requests were sent,
a sync result could instead be followed by another result type. In such cases,
discardUntilSync() mishandled the results, leading to the assertion failure.

This commit fixes the issue by making discardUntilSync() correctly handle cases
where a pipeline sync result is followed by other result types. It now continues
discarding results until another pipeline sync followed by NULL is reached.

Backpatched to v17, where support for \syncpipeline command in pgbench was
introduced.

Author: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
Reviewed-by: Chao Li <lic(at)highgo(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/20251111105037.f3fc554616bc19891f926c5b@sraoss.co.jp
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4aa0ac05765edf6b5f0c13e18ac677287ce78206

Modified Files
--------------
src/bin/pgbench/pgbench.c | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2025-11-14 13:43:03 pgsql: pgbench: Fix assertion failure with multiple \syncpipeline in pi
Previous Message Christoph Berg 2025-11-14 12:52:59 Re: failed NUMA pages inquiry status: Operation not permitted