Infinite loop in pgbench when running COPY command
Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
From: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-10-01T09:25:00Z
Lists: pgsql-hackers
Attachments
- v01-0001-Exit-copy-state-in-pgbench-to-avoid-infinite-loo.patch (application/octet-stream)
Hi, Currently, pgbench processes a copy response as unexpected and will move to the error loop. However, PQgetResult will alway return an empty result when there's no async result through getCopyResult, leading to an infinite loop in the error handling as res will never be NULL. This patch forcefully exits the copy state with PQendcopy before moving to the error handler, avoiding the infinite loop. Regards, Anthonin Bonnefoy