aboutsummaryrefslogtreecommitdiff
path: root/src/backend/bootstrap/bootstrap.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-12-17 12:23:26 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2024-12-17 12:23:26 -0500
commit21fb39cb07938d29f2c7cfcf627d1b3d6b48e61c (patch)
tree17de3a2f8ae0d9f20e4a2977ad720ab5fcf1df15 /src/backend/bootstrap/bootstrap.c
parentc91963da1302e8dd490bde115f3956f7d2f1258d (diff)
downloadpostgresql-21fb39cb07938d29f2c7cfcf627d1b3d6b48e61c.tar.gz
postgresql-21fb39cb07938d29f2c7cfcf627d1b3d6b48e61c.zip
Set max_safe_fds whenever we create shared memory and semaphores.
Formerly we skipped this in bootstrap/check mode and in single-user mode. That's bad in check mode because it may allow accepting a value of max_connections that doesn't actually work: on platforms where semaphores consume file descriptors, there may not be enough free FDs left over to satisfy fd.c, causing postmaster start to fail. It's also not great in single-user mode, because fd.c will operate with just the minimum allowable value of max_safe_fds, resulting in excess file open/close overhead if anything moderately complicated is done in single-user mode. (There may be some penalty for bootstrap mode too, though probably not much.) Discussion: https://postgr.es/m/2081982.1734393311@sss.pgh.pa.us
Diffstat (limited to 'src/backend/bootstrap/bootstrap.c')
-rw-r--r--src/backend/bootstrap/bootstrap.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index a5217773ffc..f3a7a007f77 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -335,6 +335,12 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
CreateSharedMemoryAndSemaphores();
/*
+ * Estimate number of openable files. This is essential too in --check
+ * mode, because on some platforms semaphores count as open files.
+ */
+ set_max_safe_fds();
+
+ /*
* XXX: It might make sense to move this into its own function at some
* point. Right now it seems like it'd cause more code duplication than
* it's worth.