Suggestion to add --continue-client-on-abort option to pgbench
Rintaro Ikeda <ikedarintarof@oss.nttdata.com>
From: ikedarintarof <ikedarintarof@oss.nttdata.com>
To: pgsql-hackers@postgresql.org
Date: 2025-05-10T13:45:31Z
Lists: pgsql-hackers
Attachments
- 0001-add-continue-client-on-error-option-to-pgbench.patch (text/x-diff) patch 0001
Hi hackers, I would like to suggest adding a new option to pgbench, which enables the client to continue processing transactions even if some errors occur during a transaction. Currently, a client stops sending requests when its transaction is aborted due to reasons other than serialization failures or deadlocks. I think in some cases, especially when using custom scripts, the client should be able to rollback the failed transaction and start a new one. For example, my custom script (insert_to_unique_column.sql) follows: ``` CREATE TABLE IF NOT EXISTS test (col1 serial, col2 int unique); INSERT INTO test (col2) VALUES (random(0, 50000)); ``` Assume we need to continuously apply load to the server using 5 clients for a certain period of time. However, a client sometimes stops when its transaction in my custom script is aborted due to a check constraint violation. As a result, the load on the server is lower than expected, which is the problem I want to address. The proposed new option solves this problem. When --continue-client-on-abort is set to true, the client rolls back the failed transaction and starts a new one. This allows all 5 clients to continuously apply load to the server, even if some transactions fail. ``` % bin/pgbench -d postgres -f ../insert_to_unique_column.sql -T 10 --failures-detailed --continue-client-on-error transaction type: ../custom_script_insert.sql scaling factor: 1 query mode: simple number of clients: 1 number of threads: 1 maximum number of tries: 1 duration: 10 s number of transactions actually processed: 33552 number of failed transactions: 21901 (39.495%) number of serialization failures: 0 (0.000%) number of deadlock failures: 0 (0.000%) number of other failures: 21901 (39.495%) latency average = 0.180 ms (including failures) initial connection time = 2.857 ms tps = 3356.092385 (without initial connection time) ``` I have attached the patch. I would appreciate your feedback. Best regards, Rintaro Ikeda NTT DATA Corporation Japan
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
pgbench: Fix assertion failure with multiple \syncpipeline in pipeline mode.
- 5bc251b28839 17.8 landed
- 00e64e35c8bd 18.2 landed
- 4aa0ac05765e 19 (unreleased) landed
-
pgbench: Add --continue-on-error option.
- 0ab208fa505c 19 (unreleased) landed
-
Fix "inconsistent DLL linkage" warning on Windows MSVC
- a3ea5330fcf4 19 (unreleased) cited
-
pgbench: Fix error reporting in readCommandResponse().
- 7d7e81d1e6b8 13.23 landed
- cb21e1f92fb3 14.20 landed
- bdccb6302871 15.15 landed
- 36c4d30c8f24 16.11 landed
- a912118c6055 17.7 landed
- 29aabbc43269 18.1 landed
- 19d4f9ffc207 19 (unreleased) landed
-
pgbench: Fix assertion failure with retriable errors in pipeline mode.
- 704f517711b4 15.15 landed
- 8b2e290bde21 16.11 landed
- f39d9164b70a 17.7 landed
- c736808e03b7 18.1 landed
- 8bb174295e89 19 (unreleased) landed
-
Allow pgbench to retry in some cases.
- 4a39f87acd6e 15.0 cited