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

Commitdfbba2c

Browse files
committed
Make sure MaxBackends is always set
Auxiliary and bootstrap processes weren't getting it, causing initdb tofail completely.
1 parentcdbc0ca commitdfbba2c

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,9 @@ PostmasterMain(int argc, char *argv[])
899899

900900
/*
901901
* Now that loadable modules have had their chance to register background
902-
* workers, calculate MaxBackends. Add one for the autovacuum launcher.
902+
* workers, calculate MaxBackends.
903903
*/
904-
MaxBackends=MaxConnections+autovacuum_max_workers+1+
905-
GetNumShmemAttachedBgworkers();
906-
/* internal error because the values were all checked previously */
907-
if (MaxBackends>MAX_BACKENDS)
908-
elog(ERROR,"too many backends configured");
904+
InitializeMaxBackends();
909905

910906
/*
911907
* Establish input sockets.

‎src/backend/utils/init/postinit.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,26 @@ pg_split_opts(char **argv, int *argcp, char *optstr)
421421
}
422422
}
423423

424+
/*
425+
* Initialize MaxBackends value from config options.
426+
*
427+
* This must be called after modules have had the chance to register background
428+
* workers in shared_preload_libraries, and before shared memory size is
429+
* determined.
430+
*/
431+
void
432+
InitializeMaxBackends(void)
433+
{
434+
Assert(MaxBackends==0);
435+
436+
/* the extra unit accounts for the autovacuum launcher */
437+
MaxBackends=MaxConnections+autovacuum_max_workers+1+
438+
GetNumShmemAttachedBgworkers();
439+
440+
/* internal error because the values were all checked previously */
441+
if (MaxBackends>MAX_BACKENDS)
442+
elog(ERROR,"too many backends configured");
443+
}
424444

425445
/*
426446
* Early initialization of a backend (either standalone or under postmaster).
@@ -433,6 +453,8 @@ pg_split_opts(char **argv, int *argcp, char *optstr)
433453
void
434454
BaseInit(void)
435455
{
456+
InitializeMaxBackends();
457+
436458
/*
437459
* Attach to shared memory and semaphores, and initialize our
438460
* input/output/debugging file descriptors.

‎src/include/miscadmin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ extern AuxProcType MyAuxProcType;
394394

395395
/* in utils/init/postinit.c */
396396
externvoidpg_split_opts(char**argv,int*argcp,char*optstr);
397+
externvoidInitializeMaxBackends(void);
397398
externvoidInitPostgres(constchar*in_dbname,Oiddboid,constchar*username,
398399
char*out_dbname);
399400
externvoidBaseInit(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp