Make pgbench exit on SIGINT more reliably

From: "Tristan Partin" <tristan(at)neon(dot)tech>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Make pgbench exit on SIGINT more reliably
Date: 2023-05-22 15:02:02
Message-ID: CSSWBAX56CVY.291H6ZNNHK7EO@c3po
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

The way that pgbench handled SIGINT changed in
1d468b9ad81b9139b4a0b16b416c3597925af4b0. Unfortunately this had a
couple of unintended consequences, at least from what I can tell[1].

- CTRL-C no longer stops the program unless the right point in pgbench
execution is hit
- pgbench no longer exits with a non-zero exit code

An easy reproduction of these problems is to run with a large scale
factor like: pgbench -i -s 500000. Then try to CTRL-C the program.

The attached set of patches fixes this problem by allowing callers of
setup_cancel_handler() to attach a post-PQcancel callback. In this case,
we just call _exit(2). In addition, I noticed that psql had an EXIT_USER
constant, so I moved the common exit codes from src/bin/psql/settings.h
to src/include/fe_utils/exit_codes.h and made pgbench exit with
EXIT_USER.

[1]: https://www.postgresql.org/message-id/alpine.DEB.2.21.1910311939430.27369@lancre
--
Tristan Partin
Neon (https://neon.tech)

Attachment Content-Type Size
v1-0001-Move-exit-code-definitions-to-fe_utils.patch text/x-patch 2.9 KB
v1-0002-Add-a-post-PQcancel-hook-to-setup_cancel_handler.patch text/x-patch 7.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Abhijit Menon-Sen 2023-05-22 15:03:34 Re: Naming of gss_accept_deleg
Previous Message Aleksander Alekseev 2023-05-22 14:04:06 Re: "38.10.10. Shared Memory and LWLocks" may require a clarification