Re: pgbench: make verbose error messages thread-safe

Fujii Masao <masao.fujii@gmail.com>

From: Fujii Masao <masao.fujii@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-24T11:23:50Z
Lists: pgsql-hackers
On Fri, Apr 24, 2026 at 6:06 PM Chao Li <li.evan.chao@gmail.com> wrote:
> I am not too worried about that, because this code path is only used with --verbose-errors and only when printing error messages. In that situation, the cost of one extra memory allocation per log line should be much smaller than the I/O cost of writing the log message itself. So I think the simpler fix is probably acceptable.

Yes, I feel the same way.


> But if we really care about the performance problem, I think PQExpBuffer might be better stored in TState that is per thread, while CState is per connection.

Agreed.

Regards,

-- 
Fujii Masao



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. pgbench: fix verbose error message corruption with multiple threads