Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21fb39c

Browse files
committed
Set max_safe_fds whenever we create shared memory and semaphores.
Formerly we skipped this in bootstrap/check mode and in single-usermode. That's bad in check mode because it may allow accepting avalue of max_connections that doesn't actually work: on platformswhere semaphores consume file descriptors, there may not be enoughfree FDs left over to satisfy fd.c, causing postmaster start tofail. It's also not great in single-user mode, because fd.c willoperate with just the minimum allowable value of max_safe_fds,resulting in excess file open/close overhead if anything moderatelycomplicated is done in single-user mode. (There may be some penaltyfor bootstrap mode too, though probably not much.)Discussion:https://postgr.es/m/2081982.1734393311@sss.pgh.pa.us
1 parentc91963d commit21fb39c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎src/backend/bootstrap/bootstrap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
334334

335335
CreateSharedMemoryAndSemaphores();
336336

337+
/*
338+
* Estimate number of openable files. This is essential too in --check
339+
* mode, because on some platforms semaphores count as open files.
340+
*/
341+
set_max_safe_fds();
342+
337343
/*
338344
* XXX: It might make sense to move this into its own function at some
339345
* point. Right now it seems like it'd cause more code duplication than

‎src/backend/tcop/postgres.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4099,8 +4099,18 @@ PostgresSingleUserMain(int argc, char *argv[],
40994099
*/
41004100
InitializeWalConsistencyChecking();
41014101

4102+
/*
4103+
* Create shared memory etc. (Nothing's really "shared" in single-user
4104+
* mode, but we must have these data structures anyway.)
4105+
*/
41024106
CreateSharedMemoryAndSemaphores();
41034107

4108+
/*
4109+
* Estimate number of openable files. This must happen after setting up
4110+
* semaphores, because on some platforms semaphores count as open files.
4111+
*/
4112+
set_max_safe_fds();
4113+
41044114
/*
41054115
* Remember stand-alone backend startup time,roughly at the same point
41064116
* during startup that postmaster does so.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp