]> git.ipfire.org Git - thirdparty/postgresql.git/commit
pgbench: Fix assertion failure with multiple \syncpipeline in pipeline mode.
authorFujii Masao <fujii@postgresql.org>
Fri, 14 Nov 2025 13:40:39 +0000 (22:40 +0900)
committerFujii Masao <fujii@postgresql.org>
Fri, 14 Nov 2025 13:41:55 +0000 (22:41 +0900)
commit00e64e35c8bd4e5a92b76feeb7f31defd7d08bd7
treeadc614e1b945831831eb7ae6ae8b0cc860a2fb83
parent749f4ce4d9845b01ab2db6632ccd6610386dcd9e
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@sraoss.co.jp>
Reviewed-by: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/20251111105037.f3fc554616bc19891f926c5b@sraoss.co.jp
Backpatch-through: 17
src/bin/pgbench/pgbench.c