</term>
<listitem>
<para>
- Sets the maximum number of simultaneously open files allowed to each
- server subprocess. The default is one thousand files. If the kernel is enforcing
+ Sets the maximum number of open files each server subprocess is
+ allowed to open simultaneously, in addition to the files already open
+ in postmaster. The default is one thousand files.
+ </para>
+ <para>
+ If the kernel is enforcing
a safe per-process limit, you don't need to worry about this setting.
But on some platforms (notably, most BSD systems), the kernel will
allow individual processes to open many more files than the system
/*----------
* We want to set max_safe_fds to
- * MIN(usable_fds, max_files_per_process - already_open)
+ * MIN(usable_fds, max_files_per_process)
* less the slop factor for files that are opened without consulting
- * fd.c. This ensures that we won't exceed either max_files_per_process
- * or the experimentally-determined EMFILE limit.
+ * fd.c. This ensures that we won't allow to open more than
+ * max_files_per_process, or the experimentally-determined EMFILE limit,
+ * additional files.
*----------
*/
count_usable_fds(max_files_per_process,
&usable_fds, &already_open);
- max_safe_fds = Min(usable_fds, max_files_per_process - already_open);
+ max_safe_fds = Min(usable_fds, max_files_per_process);
/*
* Take off the FDs reserved for system() etc.
ereport(FATAL,
(errcode(ERRCODE_INSUFFICIENT_RESOURCES),
errmsg("insufficient file descriptors available to start server process"),
- errdetail("System allows %d, server needs at least %d.",
+ errdetail("System allows %d, server needs at least %d, %d files are already open.",
max_safe_fds + NUM_RESERVED_FDS,
- FD_MINFREE + NUM_RESERVED_FDS)));
+ FD_MINFREE + NUM_RESERVED_FDS,
+ already_open)));
elog(DEBUG2, "max_safe_fds = %d, usable_fds = %d, already_open = %d",
max_safe_fds, usable_fds, already_open);