]> git.ipfire.org Git - thirdparty/postgresql.git/commit
pgbench: fix verbose error message corruption with multiple threads
authorFujii Masao <fujii@postgresql.org>
Thu, 14 May 2026 03:30:34 +0000 (12:30 +0900)
committerFujii Masao <fujii@postgresql.org>
Thu, 14 May 2026 03:31:25 +0000 (12:31 +0900)
commit6432a4cd68a31ff82b8daa5f713a7a24d00d6ed7
tree8cbe242a9f447a009e91d57540ee5b2bcf01f222
parent5f12d86dd762d08f7e11f3ea99d718284cbcbdf2
pgbench: fix verbose error message corruption with multiple threads

When pgbench runs with multiple threads and verbose error reporting is
enabled (--verbose-errors), multiple clients can build verbose error
messages concurrently. Previously, a function-local static
PQExpBuffer was used for these messages, causing the buffer to be
shared across threads. This was not thread-safe and could result in
corrupted or incorrect log output.

Fix this by using a local PQExpBufferData instead of a static buffer.
This keeps verbose error messages correct during concurrent execution.

Backpatch to v15, where this issue was introduced.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Alex Guo <guo.alex.hengchen@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwER1AjGXpkKB9t9820NBhMQ_Ghv7=HsKeodUr3=SZsF4g@mail.gmail.com
Backpatch-through: 15
src/bin/pgbench/pgbench.c