PostgreSQL Source Code  git master
postmaster.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define POSTMASTER_FD_WATCH
 
#define POSTMASTER_FD_OWN   1 /* kept open by postmaster only */
 
#define MAX_BACKENDS   0x3FFFF
 

Functions

void PostmasterMain (int argc, char *argv[]) pg_attribute_noreturn()
 
void ClosePostmasterPorts (bool am_syslogger)
 
void InitProcessGlobals (void)
 
int MaxLivePostmasterChildren (void)
 
bool PostmasterMarkPIDForWorkerNotify (int)
 

Variables

PGDLLIMPORT bool EnableSSL
 
PGDLLIMPORT int SuperuserReservedConnections
 
PGDLLIMPORT int ReservedConnections
 
PGDLLIMPORT int PostPortNumber
 
PGDLLIMPORT int Unix_socket_permissions
 
PGDLLIMPORT char * Unix_socket_group
 
PGDLLIMPORT char * Unix_socket_directories
 
PGDLLIMPORT char * ListenAddresses
 
PGDLLIMPORT bool ClientAuthInProgress
 
PGDLLIMPORT int PreAuthDelay
 
PGDLLIMPORT int AuthenticationTimeout
 
PGDLLIMPORT bool Log_connections
 
PGDLLIMPORT bool log_hostname
 
PGDLLIMPORT bool enable_bonjour
 
PGDLLIMPORT char * bonjour_name
 
PGDLLIMPORT bool restart_after_crash
 
PGDLLIMPORT bool remove_temp_files_after_crash
 
PGDLLIMPORT bool send_abort_for_crash
 
PGDLLIMPORT bool send_abort_for_kill
 
PGDLLIMPORT int postmaster_alive_fds [2]
 
PGDLLIMPORT const char * progname
 

Macro Definition Documentation

◆ MAX_BACKENDS

#define MAX_BACKENDS   0x3FFFF

Definition at line 78 of file postmaster.h.

◆ POSTMASTER_FD_OWN

#define POSTMASTER_FD_OWN   1 /* kept open by postmaster only */

Definition at line 47 of file postmaster.h.

◆ POSTMASTER_FD_WATCH

#define POSTMASTER_FD_WATCH
Value:
0 /* used in children to check for
* postmaster death */

Definition at line 46 of file postmaster.h.

Function Documentation

◆ ClosePostmasterPorts()

void ClosePostmasterPorts ( bool  am_syslogger)

Definition at line 2549 of file postmaster.c.

2550 {
2551  /* Release resources held by the postmaster's WaitEventSet. */
2552  if (pm_wait_set)
2553  {
2555  pm_wait_set = NULL;
2556  }
2557 
2558 #ifndef WIN32
2559 
2560  /*
2561  * Close the write end of postmaster death watch pipe. It's important to
2562  * do this as early as possible, so that if postmaster dies, others won't
2563  * think that it's still running because we're holding the pipe open.
2564  */
2566  ereport(FATAL,
2568  errmsg_internal("could not close postmaster death monitoring pipe in child process: %m")));
2570  /* Notify fd.c that we released one pipe FD. */
2572 #endif
2573 
2574  /*
2575  * Close the postmaster's listen sockets. These aren't tracked by fd.c,
2576  * so we don't call ReleaseExternalFD() here.
2577  *
2578  * The listen sockets are marked as FD_CLOEXEC, so this isn't needed in
2579  * EXEC_BACKEND mode.
2580  */
2581 #ifndef EXEC_BACKEND
2582  for (int i = 0; i < MAXLISTEN; i++)
2583  {
2585  {
2588  }
2589  }
2590 #endif
2591 
2592  /*
2593  * If using syslogger, close the read side of the pipe. We don't bother
2594  * tracking this in fd.c, either.
2595  */
2596  if (!am_syslogger)
2597  {
2598 #ifndef WIN32
2599  if (syslogPipe[0] >= 0)
2600  close(syslogPipe[0]);
2601  syslogPipe[0] = -1;
2602 #else
2603  if (syslogPipe[0])
2604  CloseHandle(syslogPipe[0]);
2605  syslogPipe[0] = 0;
2606 #endif
2607  }
2608 
2609 #ifdef USE_BONJOUR
2610  /* If using Bonjour, close the connection to the mDNS daemon */
2611  if (bonjour_sdref)
2612  close(DNSServiceRefSockFD(bonjour_sdref));
2613 #endif
2614 }
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1156
int errcode_for_file_access(void)
Definition: elog.c:881
#define FATAL
Definition: elog.h:41
#define ereport(elevel,...)
Definition: elog.h:149
void ReleaseExternalFD(void)
Definition: fd.c:1191
#define close(a)
Definition: win32.h:12
int i
Definition: isn.c:73
void FreeWaitEventSetAfterFork(WaitEventSet *set)
Definition: latch.c:874
#define PGINVALID_SOCKET
Definition: port.h:31
int postmaster_alive_fds[2]
Definition: postmaster.c:575
static WaitEventSet * pm_wait_set
Definition: postmaster.c:383
#define MAXLISTEN
Definition: postmaster.c:229
static pgsocket ListenSocket[MAXLISTEN]
Definition: postmaster.c:230
#define POSTMASTER_FD_OWN
Definition: postmaster.h:47
void StreamClose(pgsocket sock)
Definition: pqcomm.c:835
int syslogPipe[2]
Definition: syslogger.c:117

References close, ereport, errcode_for_file_access(), errmsg_internal(), FATAL, FreeWaitEventSetAfterFork(), i, ListenSocket, MAXLISTEN, PGINVALID_SOCKET, pm_wait_set, postmaster_alive_fds, POSTMASTER_FD_OWN, ReleaseExternalFD(), StreamClose(), and syslogPipe.

Referenced by BackendStartup(), do_start_bgworker(), StartAutoVacWorker(), StartChildProcess(), and SysLogger_Start().

◆ InitProcessGlobals()

void InitProcessGlobals ( void  )

Definition at line 2623 of file postmaster.c.

2624 {
2625  MyProcPid = getpid();
2628 
2629  /*
2630  * Set a different global seed in every process. We want something
2631  * unpredictable, so if possible, use high-quality random bits for the
2632  * seed. Otherwise, fall back to a seed based on timestamp and PID.
2633  */
2635  {
2636  uint64 rseed;
2637 
2638  /*
2639  * Since PIDs and timestamps tend to change more frequently in their
2640  * least significant bits, shift the timestamp left to allow a larger
2641  * total number of seeds in a given time period. Since that would
2642  * leave only 20 bits of the timestamp that cycle every ~1 second,
2643  * also mix in some higher bits.
2644  */
2645  rseed = ((uint64) MyProcPid) ^
2646  ((uint64) MyStartTimestamp << 12) ^
2647  ((uint64) MyStartTimestamp >> 20);
2648 
2650  }
2651 
2652  /*
2653  * Also make sure that we've set a good seed for random(3). Use of that
2654  * is deprecated in core Postgres, but extensions might use it.
2655  */
2656 #ifndef WIN32
2658 #endif
2659 }
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1583
pg_time_t timestamptz_to_time_t(TimestampTz t)
Definition: timestamp.c:1762
#define unlikely(x)
Definition: c.h:300
int MyProcPid
Definition: globals.c:44
TimestampTz MyStartTimestamp
Definition: globals.c:46
pg_time_t MyStartTime
Definition: globals.c:45
uint32 pg_prng_uint32(pg_prng_state *state)
Definition: pg_prng.c:191
void pg_prng_seed(pg_prng_state *state, uint64 seed)
Definition: pg_prng.c:89
pg_prng_state pg_global_prng_state
Definition: pg_prng.c:34
#define pg_prng_strong_seed(state)
Definition: pg_prng.h:46

References GetCurrentTimestamp(), MyProcPid, MyStartTime, MyStartTimestamp, pg_global_prng_state, pg_prng_seed(), pg_prng_strong_seed, pg_prng_uint32(), timestamptz_to_time_t(), and unlikely.

Referenced by InitPostmasterChild(), InitStandaloneProcess(), and PostmasterMain().

◆ MaxLivePostmasterChildren()

int MaxLivePostmasterChildren ( void  )

Definition at line 5568 of file postmaster.c.

5569 {
5570  return 2 * (MaxConnections + autovacuum_max_workers + 1 +
5572 }
int autovacuum_max_workers
Definition: autovacuum.c:117
int MaxConnections
Definition: globals.c:137
int max_worker_processes
Definition: globals.c:138
int max_wal_senders
Definition: walsender.c:122

References autovacuum_max_workers, max_wal_senders, max_worker_processes, and MaxConnections.

Referenced by canAcceptConnections(), PMSignalShmemInit(), PMSignalShmemSize(), and processCancelRequest().

◆ PostmasterMain()

void PostmasterMain ( int  argc,
char *  argv[] 
)

Definition at line 585 of file postmaster.c.

586 {
587  int opt;
588  int status;
589  char *userDoption = NULL;
590  bool listen_addr_saved = false;
591  int i;
592  char *output_config_variable = NULL;
593 
595 
597 
599 
600  /*
601  * Start our win32 signal implementation
602  */
603 #ifdef WIN32
605 #endif
606 
607  /*
608  * We should not be creating any files or directories before we check the
609  * data directory (see checkDataDir()), but just in case set the umask to
610  * the most restrictive (owner-only) permissions.
611  *
612  * checkDataDir() will reset the umask based on the data directory
613  * permissions.
614  */
615  umask(PG_MODE_MASK_OWNER);
616 
617  /*
618  * By default, palloc() requests in the postmaster will be allocated in
619  * the PostmasterContext, which is space that can be recycled by backends.
620  * Allocated data that needs to be available to backends should be
621  * allocated in TopMemoryContext.
622  */
624  "Postmaster",
627 
628  /* Initialize paths to installation files */
629  getInstallationPaths(argv[0]);
630 
631  /*
632  * Set up signal handlers for the postmaster process.
633  *
634  * CAUTION: when changing this list, check for side-effects on the signal
635  * handling setup of child processes. See tcop/postgres.c,
636  * bootstrap/bootstrap.c, postmaster/bgwriter.c, postmaster/walwriter.c,
637  * postmaster/autovacuum.c, postmaster/pgarch.c, postmaster/syslogger.c,
638  * postmaster/bgworker.c and postmaster/checkpointer.c.
639  */
640  pqinitmask();
641  sigprocmask(SIG_SETMASK, &BlockSig, NULL);
642 
647  pqsignal(SIGALRM, SIG_IGN); /* ignored */
648  pqsignal(SIGPIPE, SIG_IGN); /* ignored */
650  pqsignal(SIGUSR2, dummy_handler); /* unused, reserve for children */
652 
653  /* This may configure SIGURG, depending on platform. */
656 
657  /*
658  * No other place in Postgres should touch SIGTTIN/SIGTTOU handling. We
659  * ignore those signals in a postmaster environment, so that there is no
660  * risk of a child process freezing up due to writing to stderr. But for
661  * a standalone backend, their default handling is reasonable. Hence, all
662  * child processes should just allow the inherited settings to stand.
663  */
664 #ifdef SIGTTIN
665  pqsignal(SIGTTIN, SIG_IGN); /* ignored */
666 #endif
667 #ifdef SIGTTOU
668  pqsignal(SIGTTOU, SIG_IGN); /* ignored */
669 #endif
670 
671  /* ignore SIGXFSZ, so that ulimit violations work like disk full */
672 #ifdef SIGXFSZ
673  pqsignal(SIGXFSZ, SIG_IGN); /* ignored */
674 #endif
675 
676  /* Begin accepting signals. */
677  sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
678 
679  /*
680  * Options setup
681  */
683 
684  opterr = 1;
685 
686  /*
687  * Parse command-line options. CAUTION: keep this in sync with
688  * tcop/postgres.c (the option sets should not conflict) and with the
689  * common help() function in main/main.c.
690  */
691  while ((opt = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:")) != -1)
692  {
693  switch (opt)
694  {
695  case 'B':
696  SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
697  break;
698 
699  case 'b':
700  /* Undocumented flag used for binary upgrades */
701  IsBinaryUpgrade = true;
702  break;
703 
704  case 'C':
705  output_config_variable = strdup(optarg);
706  break;
707 
708  case 'c':
709  case '-':
710  {
711  char *name,
712  *value;
713 
715  if (!value)
716  {
717  if (opt == '-')
718  ereport(ERROR,
719  (errcode(ERRCODE_SYNTAX_ERROR),
720  errmsg("--%s requires a value",
721  optarg)));
722  else
723  ereport(ERROR,
724  (errcode(ERRCODE_SYNTAX_ERROR),
725  errmsg("-c %s requires a value",
726  optarg)));
727  }
728 
730  pfree(name);
731  pfree(value);
732  break;
733  }
734 
735  case 'D':
736  userDoption = strdup(optarg);
737  break;
738 
739  case 'd':
741  break;
742 
743  case 'E':
744  SetConfigOption("log_statement", "all", PGC_POSTMASTER, PGC_S_ARGV);
745  break;
746 
747  case 'e':
748  SetConfigOption("datestyle", "euro", PGC_POSTMASTER, PGC_S_ARGV);
749  break;
750 
751  case 'F':
752  SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
753  break;
754 
755  case 'f':
757  {
758  write_stderr("%s: invalid argument for option -f: \"%s\"\n",
759  progname, optarg);
760  ExitPostmaster(1);
761  }
762  break;
763 
764  case 'h':
765  SetConfigOption("listen_addresses", optarg, PGC_POSTMASTER, PGC_S_ARGV);
766  break;
767 
768  case 'i':
769  SetConfigOption("listen_addresses", "*", PGC_POSTMASTER, PGC_S_ARGV);
770  break;
771 
772  case 'j':
773  /* only used by interactive backend */
774  break;
775 
776  case 'k':
777  SetConfigOption("unix_socket_directories", optarg, PGC_POSTMASTER, PGC_S_ARGV);
778  break;
779 
780  case 'l':
781  SetConfigOption("ssl", "true", PGC_POSTMASTER, PGC_S_ARGV);
782  break;
783 
784  case 'N':
785  SetConfigOption("max_connections", optarg, PGC_POSTMASTER, PGC_S_ARGV);
786  break;
787 
788  case 'O':
789  SetConfigOption("allow_system_table_mods", "true", PGC_POSTMASTER, PGC_S_ARGV);
790  break;
791 
792  case 'P':
793  SetConfigOption("ignore_system_indexes", "true", PGC_POSTMASTER, PGC_S_ARGV);
794  break;
795 
796  case 'p':
798  break;
799 
800  case 'r':
801  /* only used by single-user backend */
802  break;
803 
804  case 'S':
806  break;
807 
808  case 's':
809  SetConfigOption("log_statement_stats", "true", PGC_POSTMASTER, PGC_S_ARGV);
810  break;
811 
812  case 'T':
813 
814  /*
815  * This option used to be defined as sending SIGSTOP after a
816  * backend crash, but sending SIGABRT seems more useful.
817  */
818  SetConfigOption("send_abort_for_crash", "true", PGC_POSTMASTER, PGC_S_ARGV);
819  break;
820 
821  case 't':
822  {
823  const char *tmp = get_stats_option_name(optarg);
824 
825  if (tmp)
826  {
828  }
829  else
830  {
831  write_stderr("%s: invalid argument for option -t: \"%s\"\n",
832  progname, optarg);
833  ExitPostmaster(1);
834  }
835  break;
836  }
837 
838  case 'W':
839  SetConfigOption("post_auth_delay", optarg, PGC_POSTMASTER, PGC_S_ARGV);
840  break;
841 
842  default:
843  write_stderr("Try \"%s --help\" for more information.\n",
844  progname);
845  ExitPostmaster(1);
846  }
847  }
848 
849  /*
850  * Postmaster accepts no non-option switch arguments.
851  */
852  if (optind < argc)
853  {
854  write_stderr("%s: invalid argument: \"%s\"\n",
855  progname, argv[optind]);
856  write_stderr("Try \"%s --help\" for more information.\n",
857  progname);
858  ExitPostmaster(1);
859  }
860 
861  /*
862  * Locate the proper configuration files and data directory, and read
863  * postgresql.conf for the first time.
864  */
866  ExitPostmaster(2);
867 
868  if (output_config_variable != NULL)
869  {
870  /*
871  * If this is a runtime-computed GUC, it hasn't yet been initialized,
872  * and the present value is not useful. However, this is a convenient
873  * place to print the value for most GUCs because it is safe to run
874  * postmaster startup to this point even if the server is already
875  * running. For the handful of runtime-computed GUCs that we cannot
876  * provide meaningful values for yet, we wait until later in
877  * postmaster startup to print the value. We won't be able to use -C
878  * on running servers for those GUCs, but using this option now would
879  * lead to incorrect results for them.
880  */
881  int flags = GetConfigOptionFlags(output_config_variable, true);
882 
883  if ((flags & GUC_RUNTIME_COMPUTED) == 0)
884  {
885  /*
886  * "-C guc" was specified, so print GUC's value and exit. No
887  * extra permission check is needed because the user is reading
888  * inside the data dir.
889  */
890  const char *config_val = GetConfigOption(output_config_variable,
891  false, false);
892 
893  puts(config_val ? config_val : "");
894  ExitPostmaster(0);
895  }
896 
897  /*
898  * A runtime-computed GUC will be printed later on. As we initialize
899  * a server startup sequence, silence any log messages that may show
900  * up in the output generated. FATAL and more severe messages are
901  * useful to show, even if one would only expect at least PANIC. LOG
902  * entries are hidden.
903  */
904  SetConfigOption("log_min_messages", "FATAL", PGC_SUSET,
906  }
907 
908  /* Verify that DataDir looks reasonable */
909  checkDataDir();
910 
911  /* Check that pg_control exists */
913 
914  /* And switch working directory into it */
915  ChangeToDataDir();
916 
917  /*
918  * Check for invalid combinations of GUC settings.
919  */
921  {
922  write_stderr("%s: superuser_reserved_connections (%d) plus reserved_connections (%d) must be less than max_connections (%d)\n",
923  progname,
926  ExitPostmaster(1);
927  }
929  ereport(ERROR,
930  (errmsg("WAL archival cannot be enabled when wal_level is \"minimal\"")));
932  ereport(ERROR,
933  (errmsg("WAL streaming (max_wal_senders > 0) requires wal_level \"replica\" or \"logical\"")));
934 
935  /*
936  * Other one-time internal sanity checks can go here, if they are fast.
937  * (Put any slow processing further down, after postmaster.pid creation.)
938  */
939  if (!CheckDateTokenTables())
940  {
941  write_stderr("%s: invalid datetoken tables, please fix\n", progname);
942  ExitPostmaster(1);
943  }
944 
945  /*
946  * Now that we are done processing the postmaster arguments, reset
947  * getopt(3) library so that it will work correctly in subprocesses.
948  */
949  optind = 1;
950 #ifdef HAVE_INT_OPTRESET
951  optreset = 1; /* some systems need this too */
952 #endif
953 
954  /* For debugging: display postmaster environment */
955  {
956  extern char **environ;
957  char **p;
958 
959  ereport(DEBUG3,
960  (errmsg_internal("%s: PostmasterMain: initial environment dump:",
961  progname)));
962  ereport(DEBUG3,
963  (errmsg_internal("-----------------------------------------")));
964  for (p = environ; *p; ++p)
965  ereport(DEBUG3,
966  (errmsg_internal("\t%s", *p)));
967  ereport(DEBUG3,
968  (errmsg_internal("-----------------------------------------")));
969  }
970 
971  /*
972  * Create lockfile for data directory.
973  *
974  * We want to do this before we try to grab the input sockets, because the
975  * data directory interlock is more reliable than the socket-file
976  * interlock (thanks to whoever decided to put socket files in /tmp :-().
977  * For the same reason, it's best to grab the TCP socket(s) before the
978  * Unix socket(s).
979  *
980  * Also note that this internally sets up the on_proc_exit function that
981  * is responsible for removing both data directory and socket lockfiles;
982  * so it must happen before opening sockets so that at exit, the socket
983  * lockfiles go away after CloseServerPorts runs.
984  */
985  CreateDataDirLockFile(true);
986 
987  /*
988  * Read the control file (for error checking and config info).
989  *
990  * Since we verify the control file's CRC, this has a useful side effect
991  * on machines where we need a run-time test for CRC support instructions.
992  * The postmaster will do the test once at startup, and then its child
993  * processes will inherit the correct function pointer and not need to
994  * repeat the test.
995  */
997 
998  /*
999  * Register the apply launcher. It's probably a good idea to call this
1000  * before any modules had a chance to take the background worker slots.
1001  */
1003 
1004  /*
1005  * process any libraries that should be preloaded at postmaster start
1006  */
1008 
1009  /*
1010  * Initialize SSL library, if specified.
1011  */
1012 #ifdef USE_SSL
1013  if (EnableSSL)
1014  {
1015  (void) secure_initialize(true);
1016  LoadedSSL = true;
1017  }
1018 #endif
1019 
1020  /*
1021  * Now that loadable modules have had their chance to alter any GUCs,
1022  * calculate MaxBackends.
1023  */
1025 
1026  /*
1027  * Give preloaded libraries a chance to request additional shared memory.
1028  */
1030 
1031  /*
1032  * Now that loadable modules have had their chance to request additional
1033  * shared memory, determine the value of any runtime-computed GUCs that
1034  * depend on the amount of shared memory required.
1035  */
1037 
1038  /*
1039  * Now that modules have been loaded, we can process any custom resource
1040  * managers specified in the wal_consistency_checking GUC.
1041  */
1043 
1044  /*
1045  * If -C was specified with a runtime-computed GUC, we held off printing
1046  * the value earlier, as the GUC was not yet initialized. We handle -C
1047  * for most GUCs before we lock the data directory so that the option may
1048  * be used on a running server. However, a handful of GUCs are runtime-
1049  * computed and do not have meaningful values until after locking the data
1050  * directory, and we cannot safely calculate their values earlier on a
1051  * running server. At this point, such GUCs should be properly
1052  * initialized, and we haven't yet set up shared memory, so this is a good
1053  * time to handle the -C option for these special GUCs.
1054  */
1055  if (output_config_variable != NULL)
1056  {
1057  const char *config_val = GetConfigOption(output_config_variable,
1058  false, false);
1059 
1060  puts(config_val ? config_val : "");
1061  ExitPostmaster(0);
1062  }
1063 
1064  /*
1065  * Set up shared memory and semaphores.
1066  *
1067  * Note: if using SysV shmem and/or semas, each postmaster startup will
1068  * normally choose the same IPC keys. This helps ensure that we will
1069  * clean up dead IPC objects if the postmaster crashes and is restarted.
1070  */
1072 
1073  /*
1074  * Estimate number of openable files. This must happen after setting up
1075  * semaphores, because on some platforms semaphores count as open files.
1076  */
1077  set_max_safe_fds();
1078 
1079  /*
1080  * Set reference point for stack-depth checking.
1081  */
1082  (void) set_stack_base();
1083 
1084  /*
1085  * Initialize pipe (or process handle on Windows) that allows children to
1086  * wake up from sleep on postmaster death.
1087  */
1089 
1090 #ifdef WIN32
1091 
1092  /*
1093  * Initialize I/O completion port used to deliver list of dead children.
1094  */
1095  win32ChildQueue = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
1096  if (win32ChildQueue == NULL)
1097  ereport(FATAL,
1098  (errmsg("could not create I/O completion port for child queue")));
1099 #endif
1100 
1101 #ifdef EXEC_BACKEND
1102  /* Write out nondefault GUC settings for child processes to use */
1103  write_nondefault_variables(PGC_POSTMASTER);
1104 
1105  /*
1106  * Clean out the temp directory used to transmit parameters to child
1107  * processes (see internal_forkexec, below). We must do this before
1108  * launching any child processes, else we have a race condition: we could
1109  * remove a parameter file before the child can read it. It should be
1110  * safe to do so now, because we verified earlier that there are no
1111  * conflicting Postgres processes in this data directory.
1112  */
1114 #endif
1115 
1116  /*
1117  * Forcibly remove the files signaling a standby promotion request.
1118  * Otherwise, the existence of those files triggers a promotion too early,
1119  * whether a user wants that or not.
1120  *
1121  * This removal of files is usually unnecessary because they can exist
1122  * only during a few moments during a standby promotion. However there is
1123  * a race condition: if pg_ctl promote is executed and creates the files
1124  * during a promotion, the files can stay around even after the server is
1125  * brought up to be the primary. Then, if a new standby starts by using
1126  * the backup taken from the new primary, the files can exist at server
1127  * startup and must be removed in order to avoid an unexpected promotion.
1128  *
1129  * Note that promotion signal files need to be removed before the startup
1130  * process is invoked. Because, after that, they can be used by
1131  * postmaster's SIGUSR1 signal handler.
1132  */
1134 
1135  /* Do the same for logrotate signal file */
1137 
1138  /* Remove any outdated file holding the current log filenames. */
1139  if (unlink(LOG_METAINFO_DATAFILE) < 0 && errno != ENOENT)
1140  ereport(LOG,
1142  errmsg("could not remove file \"%s\": %m",
1144 
1145  /*
1146  * Initialize input sockets.
1147  *
1148  * Mark them all closed, and set up an on_proc_exit function that's
1149  * charged with closing the sockets again at postmaster shutdown.
1150  */
1151  for (i = 0; i < MAXLISTEN; i++)
1153 
1155 
1156  /*
1157  * If enabled, start up syslogger collection subprocess
1158  */
1160 
1161  /*
1162  * Reset whereToSendOutput from DestDebug (its starting state) to
1163  * DestNone. This stops ereport from sending log messages to stderr unless
1164  * Log_destination permits. We don't do this until the postmaster is
1165  * fully launched, since startup failures may as well be reported to
1166  * stderr.
1167  *
1168  * If we are in fact disabling logging to stderr, first emit a log message
1169  * saying so, to provide a breadcrumb trail for users who may not remember
1170  * that their logging is configured to go somewhere else.
1171  */
1173  ereport(LOG,
1174  (errmsg("ending log output to stderr"),
1175  errhint("Future log output will go to log destination \"%s\".",
1177 
1179 
1180  /*
1181  * Report server startup in log. While we could emit this much earlier,
1182  * it seems best to do so after starting the log collector, if we intend
1183  * to use one.
1184  */
1185  ereport(LOG,
1186  (errmsg("starting %s", PG_VERSION_STR)));
1187 
1188  /*
1189  * Establish input sockets.
1190  */
1191  if (ListenAddresses)
1192  {
1193  char *rawstring;
1194  List *elemlist;
1195  ListCell *l;
1196  int success = 0;
1197 
1198  /* Need a modifiable copy of ListenAddresses */
1199  rawstring = pstrdup(ListenAddresses);
1200 
1201  /* Parse string into list of hostnames */
1202  if (!SplitGUCList(rawstring, ',', &elemlist))
1203  {
1204  /* syntax error in list */
1205  ereport(FATAL,
1206  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1207  errmsg("invalid list syntax in parameter \"%s\"",
1208  "listen_addresses")));
1209  }
1210 
1211  foreach(l, elemlist)
1212  {
1213  char *curhost = (char *) lfirst(l);
1214 
1215  if (strcmp(curhost, "*") == 0)
1216  status = StreamServerPort(AF_UNSPEC, NULL,
1217  (unsigned short) PostPortNumber,
1218  NULL,
1220  else
1221  status = StreamServerPort(AF_UNSPEC, curhost,
1222  (unsigned short) PostPortNumber,
1223  NULL,
1225 
1226  if (status == STATUS_OK)
1227  {
1228  success++;
1229  /* record the first successful host addr in lockfile */
1230  if (!listen_addr_saved)
1231  {
1233  listen_addr_saved = true;
1234  }
1235  }
1236  else
1237  ereport(WARNING,
1238  (errmsg("could not create listen socket for \"%s\"",
1239  curhost)));
1240  }
1241 
1242  if (!success && elemlist != NIL)
1243  ereport(FATAL,
1244  (errmsg("could not create any TCP/IP sockets")));
1245 
1246  list_free(elemlist);
1247  pfree(rawstring);
1248  }
1249 
1250 #ifdef USE_BONJOUR
1251  /* Register for Bonjour only if we opened TCP socket(s) */
1253  {
1254  DNSServiceErrorType err;
1255 
1256  /*
1257  * We pass 0 for interface_index, which will result in registering on
1258  * all "applicable" interfaces. It's not entirely clear from the
1259  * DNS-SD docs whether this would be appropriate if we have bound to
1260  * just a subset of the available network interfaces.
1261  */
1262  err = DNSServiceRegister(&bonjour_sdref,
1263  0,
1264  0,
1265  bonjour_name,
1266  "_postgresql._tcp.",
1267  NULL,
1268  NULL,
1270  0,
1271  NULL,
1272  NULL,
1273  NULL);
1274  if (err != kDNSServiceErr_NoError)
1275  ereport(LOG,
1276  (errmsg("DNSServiceRegister() failed: error code %ld",
1277  (long) err)));
1278 
1279  /*
1280  * We don't bother to read the mDNS daemon's reply, and we expect that
1281  * it will automatically terminate our registration when the socket is
1282  * closed at postmaster termination. So there's nothing more to be
1283  * done here. However, the bonjour_sdref is kept around so that
1284  * forked children can close their copies of the socket.
1285  */
1286  }
1287 #endif
1288 
1290  {
1291  char *rawstring;
1292  List *elemlist;
1293  ListCell *l;
1294  int success = 0;
1295 
1296  /* Need a modifiable copy of Unix_socket_directories */
1297  rawstring = pstrdup(Unix_socket_directories);
1298 
1299  /* Parse string into list of directories */
1300  if (!SplitDirectoriesString(rawstring, ',', &elemlist))
1301  {
1302  /* syntax error in list */
1303  ereport(FATAL,
1304  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1305  errmsg("invalid list syntax in parameter \"%s\"",
1306  "unix_socket_directories")));
1307  }
1308 
1309  foreach(l, elemlist)
1310  {
1311  char *socketdir = (char *) lfirst(l);
1312 
1313  status = StreamServerPort(AF_UNIX, NULL,
1314  (unsigned short) PostPortNumber,
1315  socketdir,
1317 
1318  if (status == STATUS_OK)
1319  {
1320  success++;
1321  /* record the first successful Unix socket in lockfile */
1322  if (success == 1)
1324  }
1325  else
1326  ereport(WARNING,
1327  (errmsg("could not create Unix-domain socket in directory \"%s\"",
1328  socketdir)));
1329  }
1330 
1331  if (!success && elemlist != NIL)
1332  ereport(FATAL,
1333  (errmsg("could not create any Unix-domain sockets")));
1334 
1335  list_free_deep(elemlist);
1336  pfree(rawstring);
1337  }
1338 
1339  /*
1340  * check that we have some socket to listen on
1341  */
1342  if (ListenSocket[0] == PGINVALID_SOCKET)
1343  ereport(FATAL,
1344  (errmsg("no socket created for listening")));
1345 
1346  /*
1347  * If no valid TCP ports, write an empty line for listen address,
1348  * indicating the Unix socket must be used. Note that this line is not
1349  * added to the lock file until there is a socket backing it.
1350  */
1351  if (!listen_addr_saved)
1353 
1354  /*
1355  * Record postmaster options. We delay this till now to avoid recording
1356  * bogus options (eg, unusable port number).
1357  */
1358  if (!CreateOptsFile(argc, argv, my_exec_path))
1359  ExitPostmaster(1);
1360 
1361  /*
1362  * Write the external PID file if requested
1363  */
1364  if (external_pid_file)
1365  {
1366  FILE *fpidfile = fopen(external_pid_file, "w");
1367 
1368  if (fpidfile)
1369  {
1370  fprintf(fpidfile, "%d\n", MyProcPid);
1371  fclose(fpidfile);
1372 
1373  /* Make PID file world readable */
1374  if (chmod(external_pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
1375  write_stderr("%s: could not change permissions of external PID file \"%s\": %s\n",
1377  }
1378  else
1379  write_stderr("%s: could not write external PID file \"%s\": %s\n",
1381 
1383  }
1384 
1385  /*
1386  * Remove old temporary files. At this point there can be no other
1387  * Postgres processes running in this directory, so this should be safe.
1388  */
1390 
1391  /*
1392  * Initialize the autovacuum subsystem (again, no process start yet)
1393  */
1394  autovac_init();
1395 
1396  /*
1397  * Load configuration files for client authentication.
1398  */
1399  if (!load_hba())
1400  {
1401  /*
1402  * It makes no sense to continue if we fail to load the HBA file,
1403  * since there is no way to connect to the database in this case.
1404  */
1405  ereport(FATAL,
1406  /* translator: %s is a configuration file */
1407  (errmsg("could not load %s", HbaFileName)));
1408  }
1409  if (!load_ident())
1410  {
1411  /*
1412  * We can start up without the IDENT file, although it means that you
1413  * cannot log in using any of the authentication methods that need a
1414  * user name mapping. load_ident() already logged the details of error
1415  * to the log.
1416  */
1417  }
1418 
1419 #ifdef HAVE_PTHREAD_IS_THREADED_NP
1420 
1421  /*
1422  * On macOS, libintl replaces setlocale() with a version that calls
1423  * CFLocaleCopyCurrent() when its second argument is "" and every relevant
1424  * environment variable is unset or empty. CFLocaleCopyCurrent() makes
1425  * the process multithreaded. The postmaster calls sigprocmask() and
1426  * calls fork() without an immediate exec(), both of which have undefined
1427  * behavior in a multithreaded program. A multithreaded postmaster is the
1428  * normal case on Windows, which offers neither fork() nor sigprocmask().
1429  */
1430  if (pthread_is_threaded_np() != 0)
1431  ereport(FATAL,
1432  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1433  errmsg("postmaster became multithreaded during startup"),
1434  errhint("Set the LC_ALL environment variable to a valid locale.")));
1435 #endif
1436 
1437  /*
1438  * Remember postmaster startup time
1439  */
1441 
1442  /*
1443  * Report postmaster status in the postmaster.pid file, to allow pg_ctl to
1444  * see what's happening.
1445  */
1447 
1448  /* Start bgwriter and checkpointer so they can help with recovery */
1449  if (CheckpointerPID == 0)
1451  if (BgWriterPID == 0)
1453 
1454  /*
1455  * We're ready to rock and roll...
1456  */
1458  Assert(StartupPID != 0);
1460  pmState = PM_STARTUP;
1461 
1462  /* Some workers may be scheduled to start now */
1464 
1465  status = ServerLoop();
1466 
1467  /*
1468  * ServerLoop probably shouldn't ever return, but if it does, close down.
1469  */
1470  ExitPostmaster(status != STATUS_OK);
1471 
1472  abort(); /* not reached */
1473 }
void autovac_init(void)
Definition: autovacuum.c:3377
void pqinitmask(void)
Definition: pqsignal.c:41
sigset_t UnBlockSig
Definition: pqsignal.c:22
sigset_t BlockSig
Definition: pqsignal.c:23
bool CheckDateTokenTables(void)
Definition: datetime.c:4700
TimestampTz PgStartTime
Definition: timestamp.c:53
int secure_initialize(bool isServerStart)
Definition: be-secure.c:76
#define write_stderr(str)
Definition: parallel.c:184
#define STATUS_OK
Definition: c.h:1182
@ DestNone
Definition: dest.h:87
int Log_destination
Definition: elog.c:113
int errhint(const char *fmt,...)
Definition: elog.c:1316
char * Log_destination_string
Definition: elog.c:114
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define LOG
Definition: elog.h:31
#define DEBUG3
Definition: elog.h:28
#define WARNING
Definition: elog.h:36
#define ERROR
Definition: elog.h:39
#define LOG_DESTINATION_STDERR
Definition: elog.h:492
void err(int eval, const char *fmt,...)
Definition: err.c:43
void RemovePgTempFilesInDir(const char *tmpdirname, bool missing_ok, bool unlink_all)
Definition: fd.c:3278
void RemovePgTempFiles(void)
Definition: fd.c:3219
void set_max_safe_fds(void)
Definition: fd.c:996
#define PG_MODE_MASK_OWNER
Definition: file_perm.h:24
#define PG_TEMP_FILES_DIR
Definition: file_utils.h:57
bool IsBinaryUpgrade
Definition: globals.c:114
pid_t PostmasterPid
Definition: globals.c:99
bool IsPostmasterEnvironment
Definition: globals.c:112
char my_exec_path[MAXPGPATH]
Definition: globals.c:76
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:4176
bool SelectConfigFiles(const char *userDoption, const char *progname)
Definition: guc.c:1749
void ParseLongOption(const char *string, char **name, char **value)
Definition: guc.c:6186
void InitializeGUCOptions(void)
Definition: guc.c:1495
const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
Definition: guc.c:4200
int GetConfigOptionFlags(const char *name, bool missing_ok)
Definition: guc.c:4295
#define GUC_RUNTIME_COMPUTED
Definition: guc.h:223
@ PGC_S_OVERRIDE
Definition: guc.h:119
@ PGC_S_ARGV
Definition: guc.h:113
@ PGC_SUSET
Definition: guc.h:74
@ PGC_POSTMASTER
Definition: guc.h:70
char * HbaFileName
Definition: guc_tables.c:537
char * external_pid_file
Definition: guc_tables.c:539
bool load_ident(void)
Definition: hba.c:2964
bool load_hba(void)
Definition: hba.c:2588
static struct @148 value
static bool success
Definition: initdb.c:184
void on_proc_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:305
void InitializeShmemGUCs(void)
Definition: ipci.c:333
void CreateSharedMemoryAndSemaphores(void)
Definition: ipci.c:175
void InitializeLatchSupport(void)
Definition: latch.c:205
void ApplyLauncherRegister(void)
Definition: launcher.c:924
Assert(fmt[strlen(fmt) - 1] !='\n')
void list_free(List *list)
Definition: list.c:1545
void list_free_deep(List *list)
Definition: list.c:1559
const char * progname
Definition: main.c:45
char * pstrdup(const char *in)
Definition: mcxt.c:1644
void pfree(void *pointer)
Definition: mcxt.c:1456
MemoryContext TopMemoryContext
Definition: mcxt.c:141
MemoryContext PostmasterContext
Definition: mcxt.c:143
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:153
void ChangeToDataDir(void)
Definition: miscinit.c:449
void process_shmem_requests(void)
Definition: miscinit.c:1857
void AddToDataDirLockFile(int target_line, const char *str)
Definition: miscinit.c:1497
void InitProcessLocalLatch(void)
Definition: miscinit.c:242
void process_shared_preload_libraries(void)
Definition: miscinit.c:1829
void checkDataDir(void)
Definition: miscinit.c:336
void CreateDataDirLockFile(bool amPostmaster)
Definition: miscinit.c:1441
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:138
#define pg_hton16(x)
Definition: pg_bswap.h:120
PGDLLIMPORT int optind
Definition: getopt.c:50
PGDLLIMPORT int opterr
Definition: getopt.c:49
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:71
PGDLLIMPORT char * optarg
Definition: getopt.c:52
#define lfirst(lc)
Definition: pg_list.h:172
#define NIL
Definition: pg_list.h:68
#define PM_STATUS_STARTING
Definition: pidfile.h:51
#define LOCK_FILE_LINE_LISTEN_ADDR
Definition: pidfile.h:42
#define LOCK_FILE_LINE_PM_STATUS
Definition: pidfile.h:44
#define LOCK_FILE_LINE_SOCKET_DIR
Definition: pidfile.h:41
pqsigfunc pqsignal(int signo, pqsigfunc func)
#define strerror
Definition: port.h:251
#define fprintf
Definition: port.h:242
void set_debug_options(int debug_flag, GucContext context, GucSource source)
Definition: postgres.c:3654
CommandDest whereToSendOutput
Definition: postgres.c:88
bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
Definition: postgres.c:3683
static const char * userDoption
Definition: postgres.c:159
const char * get_stats_option_name(const char *arg)
Definition: postgres.c:3725
pg_stack_base_t set_stack_base(void)
Definition: postgres.c:3473
void InitializeMaxBackends(void)
Definition: postinit.c:559
static void ExitPostmaster(int status) pg_attribute_noreturn()
Definition: postmaster.c:5021
static void handle_pm_shutdown_request_signal(SIGNAL_ARGS)
Definition: postmaster.c:2763
static void maybe_start_bgworkers(void)
Definition: postmaster.c:5872
static void CloseServerPorts(int status, Datum arg)
Definition: postmaster.c:1480
@ PM_STARTUP
Definition: postmaster.c:323
static void InitPostmasterDeathWatchHandle(void)
Definition: postmaster.c:6473
void InitProcessGlobals(void)
Definition: postmaster.c:2623
static void handle_pm_reload_request_signal(SIGNAL_ARGS)
Definition: postmaster.c:2680
static int ServerLoop(void)
Definition: postmaster.c:1729
int PostPortNumber
Definition: postmaster.c:199
static void checkControlFile(void)
Definition: postmaster.c:1582
#define StartupDataBase()
Definition: postmaster.c:558
bool enable_bonjour
Definition: postmaster.c:241
int ReservedConnections
Definition: postmaster.c:226
static void handle_pm_pmsignal_signal(SIGNAL_ARGS)
Definition: postmaster.c:2666
static pid_t CheckpointerPID
Definition: postmaster.c:251
static pid_t BgWriterPID
Definition: postmaster.c:250
char * Unix_socket_directories
Definition: postmaster.c:202
static bool CreateOptsFile(int argc, char *argv[], char *fullprogname)
Definition: postmaster.c:5524
static void handle_pm_child_exit_signal(SIGNAL_ARGS)
Definition: postmaster.c:2942
static void getInstallationPaths(const char *argv0)
Definition: postmaster.c:1528
#define StartCheckpointer()
Definition: postmaster.c:561
@ STARTUP_RUNNING
Definition: postmaster.c:262
static void unlink_external_pid_file(int status, Datum arg)
Definition: postmaster.c:1516
#define StartBackgroundWriter()
Definition: postmaster.c:560
static StartupStatusEnum StartupStatus
Definition: postmaster.c:267
static void dummy_handler(SIGNAL_ARGS)
Definition: postmaster.c:5232
static pid_t StartupPID
Definition: postmaster.c:249
bool EnableSSL
Definition: postmaster.c:233
static PMState pmState
Definition: postmaster.c:337
char * ListenAddresses
Definition: postmaster.c:205
int SuperuserReservedConnections
Definition: postmaster.c:225
char * bonjour_name
Definition: postmaster.c:242
static pid_t SysLoggerPID
Definition: postmaster.c:256
int StreamServerPort(int family, const char *hostName, unsigned short portNumber, const char *unixSocketDir, pgsocket ListenSocket[], int MaxListen)
Definition: pqcomm.c:321
char ** environ
void pgwin32_signal_initialize(void)
Definition: signal.c:79
Definition: pg_list.h:54
void RemoveLogrotateSignalFiles(void)
Definition: syslogger.c:1636
int SysLogger_Start(void)
Definition: syslogger.c:567
#define LOG_METAINFO_DATAFILE
Definition: syslogger.h:100
bool SplitDirectoriesString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3581
bool SplitGUCList(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3702
const char * name
#define S_IROTH
Definition: win32_port.h:313
#define SIGCHLD
Definition: win32_port.h:178
#define SIGHUP
Definition: win32_port.h:168
#define S_IRGRP
Definition: win32_port.h:301
#define SIGPIPE
Definition: win32_port.h:173
#define SIGQUIT
Definition: win32_port.h:169
#define S_IRUSR
Definition: win32_port.h:289
#define SIGUSR1
Definition: win32_port.h:180
#define SIGALRM
Definition: win32_port.h:174
#define SIGUSR2
Definition: win32_port.h:181
#define SIG_IGN
Definition: win32_port.h:165
#define S_IWUSR
Definition: win32_port.h:292
int XLogArchiveMode
Definition: xlog.c:122
int wal_level
Definition: xlog.c:134
void InitializeWalConsistencyChecking(void)
Definition: xlog.c:4426
void LocalProcessControlFile(bool reset)
Definition: xlog.c:4488
@ ARCHIVE_MODE_OFF
Definition: xlog.h:60
@ WAL_LEVEL_MINIMAL
Definition: xlog.h:69
void RemovePromoteSignalFiles(void)

References AddToDataDirLockFile(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ApplyLauncherRegister(), ARCHIVE_MODE_OFF, Assert(), autovac_init(), BgWriterPID, BlockSig, bonjour_name, ChangeToDataDir(), checkControlFile(), checkDataDir(), CheckDateTokenTables(), CheckpointerPID, CloseServerPorts(), CreateDataDirLockFile(), CreateOptsFile(), CreateSharedMemoryAndSemaphores(), DEBUG3, DestNone, dummy_handler(), enable_bonjour, EnableSSL, environ, ereport, err(), errcode(), errcode_for_file_access(), errhint(), errmsg(), errmsg_internal(), ERROR, ExitPostmaster(), external_pid_file, FATAL, fprintf, get_stats_option_name(), GetConfigOption(), GetConfigOptionFlags(), GetCurrentTimestamp(), getInstallationPaths(), getopt(), GUC_RUNTIME_COMPUTED, handle_pm_child_exit_signal(), handle_pm_pmsignal_signal(), handle_pm_reload_request_signal(), handle_pm_shutdown_request_signal(), HbaFileName, i, InitializeGUCOptions(), InitializeLatchSupport(), InitializeMaxBackends(), InitializeShmemGUCs(), InitializeWalConsistencyChecking(), InitPostmasterDeathWatchHandle(), InitProcessGlobals(), InitProcessLocalLatch(), IsBinaryUpgrade, IsPostmasterEnvironment, lfirst, list_free(), list_free_deep(), ListenAddresses, ListenSocket, load_hba(), load_ident(), LocalProcessControlFile(), LOCK_FILE_LINE_LISTEN_ADDR, LOCK_FILE_LINE_PM_STATUS, LOCK_FILE_LINE_SOCKET_DIR, LOG, Log_destination, LOG_DESTINATION_STDERR, Log_destination_string, LOG_METAINFO_DATAFILE, max_wal_senders, MaxConnections, MAXLISTEN, maybe_start_bgworkers(), MemoryContextSwitchTo(), my_exec_path, MyProcPid, name, NIL, on_proc_exit(), optarg, opterr, optind, ParseLongOption(), pfree(), pg_hton16, PG_MODE_MASK_OWNER, PG_TEMP_FILES_DIR, PGC_POSTMASTER, PGC_S_ARGV, PGC_S_OVERRIDE, PGC_SUSET, PGINVALID_SOCKET, PgStartTime, pgwin32_signal_initialize(), PM_STARTUP, PM_STATUS_STARTING, pmState, PostmasterContext, PostmasterPid, PostPortNumber, pqinitmask(), pqsignal(), process_shared_preload_libraries(), process_shmem_requests(), progname, pstrdup(), RemoveLogrotateSignalFiles(), RemovePgTempFiles(), RemovePgTempFilesInDir(), RemovePromoteSignalFiles(), ReservedConnections, S_IRGRP, S_IROTH, S_IRUSR, S_IWUSR, secure_initialize(), SelectConfigFiles(), ServerLoop(), set_debug_options(), set_max_safe_fds(), set_plan_disabling_options(), set_stack_base(), SetConfigOption(), SIG_IGN, SIGALRM, SIGCHLD, SIGHUP, SIGPIPE, SIGQUIT, SIGUSR1, SIGUSR2, SplitDirectoriesString(), SplitGUCList(), StartBackgroundWriter, StartCheckpointer, STARTUP_RUNNING, StartupDataBase, StartupPID, StartupStatus, STATUS_OK, StreamServerPort(), strerror, success, SuperuserReservedConnections, SysLogger_Start(), SysLoggerPID, TopMemoryContext, UnBlockSig, Unix_socket_directories, unlink_external_pid_file(), userDoption, value, wal_level, WAL_LEVEL_MINIMAL, WARNING, whereToSendOutput, write_stderr, and XLogArchiveMode.

Referenced by main().

◆ PostmasterMarkPIDForWorkerNotify()

bool PostmasterMarkPIDForWorkerNotify ( int  pid)

Definition at line 5991 of file postmaster.c.

5992 {
5993  dlist_iter iter;
5994  Backend *bp;
5995 
5996  dlist_foreach(iter, &BackendList)
5997  {
5998  bp = dlist_container(Backend, elem, iter.cur);
5999  if (bp->pid == pid)
6000  {
6001  bp->bgworker_notify = true;
6002  return true;
6003  }
6004  }
6005  return false;
6006 }
#define dlist_foreach(iter, lhead)
Definition: ilist.h:623
#define dlist_container(type, membername, ptr)
Definition: ilist.h:593
static dlist_head BackendList
Definition: postmaster.c:188
bool bgworker_notify
Definition: postmaster.c:184
pid_t pid
Definition: postmaster.c:179
dlist_node * cur
Definition: ilist.h:179

References BackendList, bkend::bgworker_notify, dlist_iter::cur, dlist_container, dlist_foreach, and bkend::pid.

Referenced by BackgroundWorkerStateChange().

Variable Documentation

◆ AuthenticationTimeout

PGDLLIMPORT int AuthenticationTimeout
extern

Definition at line 236 of file postmaster.c.

Referenced by BackendInitialize(), and PerformAuthentication().

◆ bonjour_name

PGDLLIMPORT char* bonjour_name
extern

Definition at line 242 of file postmaster.c.

Referenced by PostmasterMain().

◆ ClientAuthInProgress

◆ enable_bonjour

PGDLLIMPORT bool enable_bonjour
extern

Definition at line 241 of file postmaster.c.

Referenced by PostmasterMain().

◆ EnableSSL

PGDLLIMPORT bool EnableSSL
extern

Definition at line 233 of file postmaster.c.

Referenced by parse_hba_line(), PostmasterMain(), and process_pm_reload_request().

◆ ListenAddresses

PGDLLIMPORT char* ListenAddresses
extern

Definition at line 205 of file postmaster.c.

Referenced by PostmasterMain().

◆ Log_connections

PGDLLIMPORT bool Log_connections
extern

◆ log_hostname

PGDLLIMPORT bool log_hostname
extern

Definition at line 238 of file postmaster.c.

Referenced by BackendInitialize().

◆ postmaster_alive_fds

◆ PostPortNumber

PGDLLIMPORT int PostPortNumber
extern

Definition at line 199 of file postmaster.c.

Referenced by CreateLockFile(), and PostmasterMain().

◆ PreAuthDelay

PGDLLIMPORT int PreAuthDelay
extern

Definition at line 235 of file postmaster.c.

Referenced by BackendInitialize().

◆ progname

◆ remove_temp_files_after_crash

PGDLLIMPORT bool remove_temp_files_after_crash
extern

Definition at line 244 of file postmaster.c.

Referenced by PostmasterStateMachine().

◆ ReservedConnections

PGDLLIMPORT int ReservedConnections
extern

Definition at line 226 of file postmaster.c.

Referenced by InitPostgres(), and PostmasterMain().

◆ restart_after_crash

PGDLLIMPORT bool restart_after_crash
extern

Definition at line 243 of file postmaster.c.

Referenced by PostmasterStateMachine().

◆ send_abort_for_crash

PGDLLIMPORT bool send_abort_for_crash
extern

Definition at line 245 of file postmaster.c.

Referenced by sigquit_child().

◆ send_abort_for_kill

PGDLLIMPORT bool send_abort_for_kill
extern

Definition at line 246 of file postmaster.c.

Referenced by ServerLoop().

◆ SuperuserReservedConnections

PGDLLIMPORT int SuperuserReservedConnections
extern

Definition at line 225 of file postmaster.c.

Referenced by InitPostgres(), and PostmasterMain().

◆ Unix_socket_directories

PGDLLIMPORT char* Unix_socket_directories
extern

Definition at line 202 of file postmaster.c.

Referenced by PostmasterMain().

◆ Unix_socket_group

PGDLLIMPORT char* Unix_socket_group
extern

Definition at line 107 of file pqcomm.c.

Referenced by Setup_AF_UNIX().

◆ Unix_socket_permissions

PGDLLIMPORT int Unix_socket_permissions
extern

Definition at line 106 of file pqcomm.c.

Referenced by Setup_AF_UNIX(), and show_unix_socket_permissions().