mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -193,9 +193,14 @@ CheckerModeMain(void)
|
|||||||
* The bootstrap mode is used to initialize the template database.
|
* The bootstrap mode is used to initialize the template database.
|
||||||
* The bootstrap backend doesn't speak SQL, but instead expects
|
* The bootstrap backend doesn't speak SQL, but instead expects
|
||||||
* commands in a special bootstrap language.
|
* commands in a special bootstrap language.
|
||||||
|
*
|
||||||
|
* When check_only is true, startup is done only far enough to verify that
|
||||||
|
* the current configuration, particularly the passed in options pertaining
|
||||||
|
* to shared memory sizing, options work (or at least do not cause an error
|
||||||
|
* up to shared memory creation).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BootstrapModeMain(int argc, char *argv[])
|
BootstrapModeMain(int argc, char *argv[], bool check_only)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *progname = argv[0];
|
char *progname = argv[0];
|
||||||
@ -209,16 +214,14 @@ BootstrapModeMain(int argc, char *argv[])
|
|||||||
/* Set defaults, to be overridden by explicit options below */
|
/* Set defaults, to be overridden by explicit options below */
|
||||||
InitializeGUCOptions();
|
InitializeGUCOptions();
|
||||||
|
|
||||||
/* an initial --boot should be present */
|
/* an initial --boot or --check should be present */
|
||||||
Assert(argc == 1
|
Assert(argc == 1
|
||||||
|| strcmp(argv[1], "--boot") != 0);
|
|| strcmp(argv[1], "--boot") != 0
|
||||||
|
|| strcmp(argv[1], "--check") != 0);
|
||||||
argv++;
|
argv++;
|
||||||
argc--;
|
argc--;
|
||||||
|
|
||||||
/* If no -x argument, we are a CheckerProcess */
|
while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:X:-:")) != -1)
|
||||||
MyAuxProcType = CheckerProcess;
|
|
||||||
|
|
||||||
while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:x:X:-:")) != -1)
|
|
||||||
{
|
{
|
||||||
switch (flag)
|
switch (flag)
|
||||||
{
|
{
|
||||||
@ -250,16 +253,6 @@ BootstrapModeMain(int argc, char *argv[])
|
|||||||
case 'r':
|
case 'r':
|
||||||
strlcpy(OutputFileName, optarg, MAXPGPATH);
|
strlcpy(OutputFileName, optarg, MAXPGPATH);
|
||||||
break;
|
break;
|
||||||
case 'x':
|
|
||||||
MyAuxProcType = atoi(optarg);
|
|
||||||
if (MyAuxProcType != CheckerProcess &&
|
|
||||||
MyAuxProcType != BootstrapProcess)
|
|
||||||
{
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
|
||||||
errmsg("-x %s is invalid", optarg)));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'X':
|
case 'X':
|
||||||
{
|
{
|
||||||
int WalSegSz = strtoul(optarg, NULL, 0);
|
int WalSegSz = strtoul(optarg, NULL, 0);
|
||||||
@ -338,7 +331,7 @@ BootstrapModeMain(int argc, char *argv[])
|
|||||||
* point. Right now it seems like it'd cause more code duplication than
|
* point. Right now it seems like it'd cause more code duplication than
|
||||||
* it's worth.
|
* it's worth.
|
||||||
*/
|
*/
|
||||||
if (MyAuxProcType == CheckerProcess)
|
if (check_only)
|
||||||
{
|
{
|
||||||
SetProcessingMode(NormalProcessing);
|
SetProcessingMode(NormalProcessing);
|
||||||
CheckerModeMain();
|
CheckerModeMain();
|
||||||
|
@ -197,8 +197,10 @@ main(int argc, char *argv[])
|
|||||||
pgwin32_signal_initialize();
|
pgwin32_signal_initialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argc > 1 && strcmp(argv[1], "--boot") == 0)
|
if (argc > 1 && strcmp(argv[1], "--check") == 0)
|
||||||
BootstrapModeMain(argc, argv); /* does not return */
|
BootstrapModeMain(argc, argv, true);
|
||||||
|
else if (argc > 1 && strcmp(argv[1], "--boot") == 0)
|
||||||
|
BootstrapModeMain(argc, argv, false);
|
||||||
else if (argc > 1 && strcmp(argv[1], "--describe-config") == 0)
|
else if (argc > 1 && strcmp(argv[1], "--describe-config") == 0)
|
||||||
GucInfoMain(); /* does not return */
|
GucInfoMain(); /* does not return */
|
||||||
else if (argc > 1 && strcmp(argv[1], "--single") == 0)
|
else if (argc > 1 && strcmp(argv[1], "--single") == 0)
|
||||||
@ -350,9 +352,9 @@ help(const char *progname)
|
|||||||
|
|
||||||
printf(_("\nOptions for bootstrapping mode:\n"));
|
printf(_("\nOptions for bootstrapping mode:\n"));
|
||||||
printf(_(" --boot selects bootstrapping mode (must be first argument)\n"));
|
printf(_(" --boot selects bootstrapping mode (must be first argument)\n"));
|
||||||
|
printf(_(" --check selects check mode (must be first argument)\n"));
|
||||||
printf(_(" DBNAME database name (mandatory argument in bootstrapping mode)\n"));
|
printf(_(" DBNAME database name (mandatory argument in bootstrapping mode)\n"));
|
||||||
printf(_(" -r FILENAME send stdout and stderr to given file\n"));
|
printf(_(" -r FILENAME send stdout and stderr to given file\n"));
|
||||||
printf(_(" -x NUM internal use\n"));
|
|
||||||
|
|
||||||
printf(_("\nPlease read the documentation for the complete list of run-time\n"
|
printf(_("\nPlease read the documentation for the complete list of run-time\n"
|
||||||
"configuration settings and how to set them on the command line or in\n"
|
"configuration settings and how to set them on the command line or in\n"
|
||||||
|
@ -142,11 +142,6 @@ AuxiliaryProcessMain(AuxProcType auxtype)
|
|||||||
|
|
||||||
switch (MyAuxProcType)
|
switch (MyAuxProcType)
|
||||||
{
|
{
|
||||||
case CheckerProcess:
|
|
||||||
case BootstrapProcess:
|
|
||||||
pg_unreachable();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case StartupProcess:
|
case StartupProcess:
|
||||||
StartupProcessMain();
|
StartupProcessMain();
|
||||||
proc_exit(1);
|
proc_exit(1);
|
||||||
|
@ -965,7 +965,7 @@ test_config_settings(void)
|
|||||||
test_buffs = MIN_BUFS_FOR_CONNS(test_conns);
|
test_buffs = MIN_BUFS_FOR_CONNS(test_conns);
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"\"%s\" --boot -x0 %s %s "
|
"\"%s\" --check %s %s "
|
||||||
"-c max_connections=%d "
|
"-c max_connections=%d "
|
||||||
"-c shared_buffers=%d "
|
"-c shared_buffers=%d "
|
||||||
"-c dynamic_shared_memory_type=%s "
|
"-c dynamic_shared_memory_type=%s "
|
||||||
@ -1001,7 +1001,7 @@ test_config_settings(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"\"%s\" --boot -x0 %s %s "
|
"\"%s\" --check %s %s "
|
||||||
"-c max_connections=%d "
|
"-c max_connections=%d "
|
||||||
"-c shared_buffers=%d "
|
"-c shared_buffers=%d "
|
||||||
"-c dynamic_shared_memory_type=%s "
|
"-c dynamic_shared_memory_type=%s "
|
||||||
@ -1406,7 +1406,7 @@ bootstrap_template1(void)
|
|||||||
unsetenv("PGCLIENTENCODING");
|
unsetenv("PGCLIENTENCODING");
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"\"%s\" --boot -x1 -X %u %s %s %s %s",
|
"\"%s\" --boot -X %u %s %s %s %s",
|
||||||
backend_exec,
|
backend_exec,
|
||||||
wal_segment_size_mb * (1024 * 1024),
|
wal_segment_size_mb * (1024 * 1024),
|
||||||
data_checksums ? "-k" : "",
|
data_checksums ? "-k" : "",
|
||||||
|
@ -32,7 +32,7 @@ extern Form_pg_attribute attrtypes[MAXATTR];
|
|||||||
extern int numattr;
|
extern int numattr;
|
||||||
|
|
||||||
|
|
||||||
extern void BootstrapModeMain(int argc, char *argv[]) pg_attribute_noreturn();
|
extern void BootstrapModeMain(int argc, char *argv[], bool check_only) pg_attribute_noreturn();
|
||||||
|
|
||||||
extern void closerel(char *name);
|
extern void closerel(char *name);
|
||||||
extern void boot_openrel(char *name);
|
extern void boot_openrel(char *name);
|
||||||
|
@ -427,9 +427,7 @@ extern ProcessingMode Mode;
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
NotAnAuxProcess = -1,
|
NotAnAuxProcess = -1,
|
||||||
CheckerProcess = 0,
|
StartupProcess = 0,
|
||||||
BootstrapProcess,
|
|
||||||
StartupProcess,
|
|
||||||
BgWriterProcess,
|
BgWriterProcess,
|
||||||
ArchiverProcess,
|
ArchiverProcess,
|
||||||
CheckpointerProcess,
|
CheckpointerProcess,
|
||||||
@ -441,7 +439,6 @@ typedef enum
|
|||||||
|
|
||||||
extern AuxProcType MyAuxProcType;
|
extern AuxProcType MyAuxProcType;
|
||||||
|
|
||||||
#define AmBootstrapProcess() (MyAuxProcType == BootstrapProcess)
|
|
||||||
#define AmStartupProcess() (MyAuxProcType == StartupProcess)
|
#define AmStartupProcess() (MyAuxProcType == StartupProcess)
|
||||||
#define AmBackgroundWriterProcess() (MyAuxProcType == BgWriterProcess)
|
#define AmBackgroundWriterProcess() (MyAuxProcType == BgWriterProcess)
|
||||||
#define AmArchiverProcess() (MyAuxProcType == ArchiverProcess)
|
#define AmArchiverProcess() (MyAuxProcType == ArchiverProcess)
|
||||||
|
Reference in New Issue
Block a user