Re: Bump soft open file limit (RLIMIT_NOFILE) to hard limit on startup

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Tomas Vondra <tomas(at)vondra(dot)me>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bump soft open file limit (RLIMIT_NOFILE) to hard limit on startup
Date: 2025-02-17 17:40:39
Message-ID: 849933.1739814039@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> writes:
> On 2025-02-12 22:52:52 +0100, Jelte Fennema-Nio wrote:
>> + /*
>> + * Bump the soft limit to the hard limit to not run into low
>> + * file limits.
>> + */
>> + rlim.rlim_cur = rlim.rlim_max;
>> + if (setrlimit(RLIMIT_NOFILE, &rlim) == -1)
>> + pg_fatal("setrlimit failed: %m");
>> +
>> if (rlim.rlim_cur < nclients + 3)

> Why not do this only in the if (rlim.rlim_cur < nclients + 3) case?

+1, otherwise you're introducing a potential failure mode for nothing.
It'd take a couple extra lines to deal with the scenario where
rlim_max is still too small, but that seems fine.

> Other than this I think we should just apply this.

Agreed on the pgbench change. I don't have an opinion yet on the
server changes.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-02-17 17:41:09 Re: Improve CRC32C performance on SSE4.2
Previous Message Tomas Vondra 2025-02-17 17:32:02 Re: psql: Add tab completion for ALTER USER RESET