pgsql: pgbench: Increase RLIMIT_NOFILE if necessary

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pgbench: Increase RLIMIT_NOFILE if necessary
Date: 2025-02-20 00:37:50
Message-ID: E1tkuZb-000DlR-1K@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pgbench: Increase RLIMIT_NOFILE if necessary

pgbench already had code to check if the soft rlimit is too low for the
specified number of connections. If too low, it errored out, telling the user
to increase the limit.

However, we can do better: If the hard limit allows, increase the soft limit
to be sufficiently for the number of connections.

It is common for the soft limit to be considerably lower than the hard limit,
due to the danger of soft limits > 1024 breaking programs that use the
select(2), as explained in [1].

[1]: https://0pointer.net/blog/file-descriptor-limits.html

Author: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAGECzQQh6VSy3KG4pN1d%3Dh9J%3DD1rStFCMR%2Bt7yh_Kwj-g87aLQ%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d38bab5edd60dbe6309512b6c8daea37ce579b70

Modified Files
--------------
src/bin/pgbench/pgbench.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-02-20 01:44:03 pgsql: Fix FATAL message for invalid recovery timeline at beginning of
Previous Message Michael Paquier 2025-02-20 00:32:02 pgsql: test_escape: Fix output of --help