Print pgbench results on SIGINT

From: Roman Khapov <rkhapov(at)yandex-team(dot)ru>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Print pgbench results on SIGINT
Date: 2026-10-26 06:41:34
Message-ID: F9B91838-37D4-420A-8DC4-5ADA4861B880@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers!

While working on [1] or [2] I sometimes use pgbench in short-run mode:
see if there is some performance improvements or degradation for 5-10 seconds,
press CTRL+C, make some code changes and repeat the measurements.

For now, pgbench prints nothing on CTRL+C, which hides the run statistics
from user. What if it printed the collected statistics anyway, along with the
existing 'Run was aborted; the above results are incomplete.' message?

Attached POC-patch does:
- on first SIGINT stops accepting new transactions, discards the in-flight ones
and print the summary as usual, exiting with status 130
- on second SIGINT fallbacks to standard handler immediately
- caps all wait at one second, so the SIGINT can interrupt the \sleep

For now I am not sure about exit code..
Any feedback would be appreciated :)

[1] - https://github.com/yandex/odyssey
[2] - https://github.com/pg-sharding/spqr/

--
Best regards,
Roman Khapov

Attachment Content-Type Size
0001-pgbench-print-partial-results-on-SIGINT.patch application/octet-stream 4.3 KB

Browse pgsql-hackers by date

  From Date Subject
Previous Message Roman Khapov 2026-10-26 06:41:28 kqueue backend for pgbench