Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f8dd4ec

Browse files
committed
process startup: Remove bootstrap / checker modes from AuxProcType.
Neither is actually initialized as an auxiliary process, so it does not really make sense to reserve a PGPROC etc for them. This keeps checker mode implemented by exiting partway through bootstrap mode. That might be worth changing at some point, perhaps if we ever extend checker mode to be a more general tool. Author: Andres Freund <andres@anarazel.de> Reviewed-By: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-By: Robert Haas <robertmhaas@gmail.com> Discussion: https://postgr.es/m/20210802164124.ufo5buo4apl6yuvs@alap3.anarazel.de
1 parent 0a69210 commit f8dd4ec

File tree

6 files changed

+21
-34
lines changed

6 files changed

+21
-34
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,14 @@ CheckerModeMain(void)
193193
* The bootstrap mode is used to initialize the template database.
194194
* The bootstrap backend doesn't speak SQL, but instead expects
195195
* commands in a special bootstrap language.
196+
*
197+
* When check_only is true, startup is done only far enough to verify that
198+
* the current configuration, particularly the passed in options pertaining
199+
* to shared memory sizing, options work (or at least do not cause an error
200+
* up to shared memory creation).
196201
*/
197202
void
198-
BootstrapModeMain(int argc, char *argv[])
203+
BootstrapModeMain(int argc, char *argv[], bool check_only)
199204
{
200205
int i;
201206
char *progname = argv[0];
@@ -209,16 +214,14 @@ BootstrapModeMain(int argc, char *argv[])
209214
/* Set defaults, to be overridden by explicit options below */
210215
InitializeGUCOptions();
211216

212-
/* an initial --boot should be present */
217+
/* an initial --boot or --check should be present */
213218
Assert(argc == 1
214-
|| strcmp(argv[1], "--boot") != 0);
219+
|| strcmp(argv[1], "--boot") != 0
220+
|| strcmp(argv[1], "--check") != 0);
215221
argv++;
216222
argc--;
217223

218-
/* If no -x argument, we are a CheckerProcess */
219-
MyAuxProcType = CheckerProcess;
220-
221-
while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:x:X:-:")) != -1)
224+
while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:X:-:")) != -1)
222225
{
223226
switch (flag)
224227
{
@@ -250,16 +253,6 @@ BootstrapModeMain(int argc, char *argv[])
250253
case 'r':
251254
strlcpy(OutputFileName, optarg, MAXPGPATH);
252255
break;
253-
case 'x':
254-
MyAuxProcType = atoi(optarg);
255-
if (MyAuxProcType != CheckerProcess &&
256-
MyAuxProcType != BootstrapProcess)
257-
{
258-
ereport(ERROR,
259-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
260-
errmsg("-x %s is invalid", optarg)));
261-
}
262-
break;
263256
case 'X':
264257
{
265258
int WalSegSz = strtoul(optarg, NULL, 0);
@@ -338,7 +331,7 @@ BootstrapModeMain(int argc, char *argv[])
338331
* point. Right now it seems like it'd cause more code duplication than
339332
* it's worth.
340333
*/
341-
if (MyAuxProcType == CheckerProcess)
334+
if (check_only)
342335
{
343336
SetProcessingMode(NormalProcessing);
344337
CheckerModeMain();

src/backend/main/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,10 @@ main(int argc, char *argv[])
197197
pgwin32_signal_initialize();
198198
#endif
199199

200-
if (argc > 1 && strcmp(argv[1], "--boot") == 0)
201-
BootstrapModeMain(argc, argv); /* does not return */
200+
if (argc > 1 && strcmp(argv[1], "--check") == 0)
201+
BootstrapModeMain(argc, argv, true);
202+
else if (argc > 1 && strcmp(argv[1], "--boot") == 0)
203+
BootstrapModeMain(argc, argv, false);
202204
else if (argc > 1 && strcmp(argv[1], "--describe-config") == 0)
203205
GucInfoMain(); /* does not return */
204206
else if (argc > 1 && strcmp(argv[1], "--single") == 0)
@@ -350,9 +352,9 @@ help(const char *progname)
350352

351353
printf(_("\nOptions for bootstrapping mode:\n"));
352354
printf(_(" --boot selects bootstrapping mode (must be first argument)\n"));
355+
printf(_(" --check selects check mode (must be first argument)\n"));
353356
printf(_(" DBNAME database name (mandatory argument in bootstrapping mode)\n"));
354357
printf(_(" -r FILENAME send stdout and stderr to given file\n"));
355-
printf(_(" -x NUM internal use\n"));
356358

357359
printf(_("\nPlease read the documentation for the complete list of run-time\n"
358360
"configuration settings and how to set them on the command line or in\n"

src/backend/postmaster/auxprocess.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ AuxiliaryProcessMain(AuxProcType auxtype)
142142

143143
switch (MyAuxProcType)
144144
{
145-
case CheckerProcess:
146-
case BootstrapProcess:
147-
pg_unreachable();
148-
break;
149-
150145
case StartupProcess:
151146
StartupProcessMain();
152147
proc_exit(1);

src/bin/initdb/initdb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ test_config_settings(void)
965965
test_buffs = MIN_BUFS_FOR_CONNS(test_conns);
966966

967967
snprintf(cmd, sizeof(cmd),
968-
"\"%s\" --boot -x0 %s %s "
968+
"\"%s\" --check %s %s "
969969
"-c max_connections=%d "
970970
"-c shared_buffers=%d "
971971
"-c dynamic_shared_memory_type=%s "
@@ -1001,7 +1001,7 @@ test_config_settings(void)
10011001
}
10021002

10031003
snprintf(cmd, sizeof(cmd),
1004-
"\"%s\" --boot -x0 %s %s "
1004+
"\"%s\" --check %s %s "
10051005
"-c max_connections=%d "
10061006
"-c shared_buffers=%d "
10071007
"-c dynamic_shared_memory_type=%s "
@@ -1406,7 +1406,7 @@ bootstrap_template1(void)
14061406
unsetenv("PGCLIENTENCODING");
14071407

14081408
snprintf(cmd, sizeof(cmd),
1409-
"\"%s\" --boot -x1 -X %u %s %s %s %s",
1409+
"\"%s\" --boot -X %u %s %s %s %s",
14101410
backend_exec,
14111411
wal_segment_size_mb * (1024 * 1024),
14121412
data_checksums ? "-k" : "",

src/include/bootstrap/bootstrap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern Form_pg_attribute attrtypes[MAXATTR];
3232
extern int numattr;
3333

3434

35-
extern void BootstrapModeMain(int argc, char *argv[]) pg_attribute_noreturn();
35+
extern void BootstrapModeMain(int argc, char *argv[], bool check_only) pg_attribute_noreturn();
3636

3737
extern void closerel(char *name);
3838
extern void boot_openrel(char *name);

src/include/miscadmin.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ extern ProcessingMode Mode;
427427
typedef enum
428428
{
429429
NotAnAuxProcess = -1,
430-
CheckerProcess = 0,
431-
BootstrapProcess,
432-
StartupProcess,
430+
StartupProcess = 0,
433431
BgWriterProcess,
434432
ArchiverProcess,
435433
CheckpointerProcess,
@@ -441,7 +439,6 @@ typedef enum
441439

442440
extern AuxProcType MyAuxProcType;
443441

444-
#define AmBootstrapProcess() (MyAuxProcType == BootstrapProcess)
445442
#define AmStartupProcess() (MyAuxProcType == StartupProcess)
446443
#define AmBackgroundWriterProcess() (MyAuxProcType == BgWriterProcess)
447444
#define AmArchiverProcess() (MyAuxProcType == ArchiverProcess)

0 commit comments

Comments
 (0)