Re: Bump soft open file limit (RLIMIT_NOFILE) to hard limit on startup
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Jelte Fennema-Nio <postgres@jeltef.nl>, Tomas Vondra <tomas@vondra.me>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-02-17T17:40:39Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.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
Commits
-
Redefine max_files_per_process to control additionally opened files
- adb5f85fa5a0 18.0 landed
-
pgbench: Increase RLIMIT_NOFILE if necessary
- d38bab5edd60 18.0 landed
-
Move extra code out of the Pre/PostRestoreCommand() section.
- 8fb13dd6ab5b 17.0 cited