]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Postpone pg_timezone_initialize() until after creation of postmaster.pid,
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 20 Oct 2005 20:06:03 +0000 (20:06 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 20 Oct 2005 20:06:03 +0000 (20:06 +0000)
since it can take a fair amount of time and this can confuse boot scripts
that expect postmaster.pid to appear quickly.  Move initialization of SSL
library and preloaded libraries to after that point, too, just for luck.
Per reports from Tony Caduto and others.

src/backend/bootstrap/bootstrap.c
src/backend/postmaster/postmaster.c
src/backend/tcop/postgres.c
src/backend/utils/misc/guc.c

index 47d68518ec84206c480346de14c07eda0c4c3150..316ce270c21dfc1085c7267256afaf971d9fca7d 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.198 2005/01/14 21:08:44 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.198.4.1 2005/10/20 20:06:02 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -354,6 +354,8 @@ BootstrapMain(int argc, char *argv[])
        {
                if (!SelectConfigFiles(userDoption, progname))
                        proc_exit(1);
+               /* If timezone is not set, determine what the OS uses */
+               pg_timezone_initialize();
        }
 
        /* Validate we have been given a reasonable-looking DataDir */
index e5162680e4323a2e096c2adf7a2973039419c730..0a67a25916f648cdc455f5654405f14c48a60ef0 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.443.4.2 2005/03/25 00:35:14 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.443.4.3 2005/10/20 20:06:02 tgl Exp $
  *
  * NOTES
  *
@@ -613,7 +613,8 @@ PostmasterMain(int argc, char *argv[])
        }
 
        /*
-        * Other one-time internal sanity checks can go here.
+        * Other one-time internal sanity checks can go here, if they are fast.
+        * (Put any slow processing further down, after postmaster.pid creation.)
         */
        if (!CheckDateTokenTables())
        {
@@ -655,21 +656,6 @@ PostmasterMain(int argc, char *argv[])
                                         progname)));
 #endif
 
-       /*
-        * Initialize SSL library, if specified.
-        */
-#ifdef USE_SSL
-       if (EnableSSL)
-               secure_initialize();
-#endif
-
-       /*
-        * process any libraries that should be preloaded and optionally
-        * pre-initialized
-        */
-       if (preload_libraries_string)
-               process_preload_libraries(preload_libraries_string);
-
        /*
         * Fork away from controlling terminal, if -S specified.
         *
@@ -690,6 +676,30 @@ PostmasterMain(int argc, char *argv[])
         */
        CreateDataDirLockFile(DataDir, true);
 
+       /*
+        * If timezone is not set, determine what the OS uses.  (In theory this
+        * should be done during GUC initialization, but because it can take as
+        * much as several seconds, we delay it until after we've created the
+        * postmaster.pid file.  This prevents problems with boot scripts that
+        * expect the pidfile to appear quickly.)
+        */
+       pg_timezone_initialize();
+
+       /*
+        * Initialize SSL library, if specified.
+        */
+#ifdef USE_SSL
+       if (EnableSSL)
+               secure_initialize();
+#endif
+
+       /*
+        * process any libraries that should be preloaded and optionally
+        * pre-initialized
+        */
+       if (preload_libraries_string)
+               process_preload_libraries(preload_libraries_string);
+
        /*
         * Remove old temporary files.  At this point there can be no other
         * Postgres processes running in this directory, so this should be
index ef2fcf1f9c1781960451d7e71ef69eba66d397d2..232a4750fd3cf64dfac0e800330e56e4fff38162 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.440.4.2 2005/06/02 21:03:46 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.440.4.3 2005/10/20 20:06:03 tgl Exp $
  *
  * NOTES
  *       this is the "main" module of the postgres backend and
@@ -2645,6 +2645,8 @@ PostgresMain(int argc, char *argv[], const char *username)
        {
                if (!SelectConfigFiles(userDoption, argv[0]))
                        proc_exit(1);
+               /* If timezone is not set, determine what the OS uses */
+               pg_timezone_initialize();
        }
 
        /*
index 9038f6604760e06924d3102e8ee6104a3ba4f1a9..dc4d290ebc3a2a0479e69ca49cef27c116216355 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.252.4.1 2005/03/25 16:17:38 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.252.4.2 2005/10/20 20:06:03 tgl Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -2584,9 +2584,6 @@ SelectConfigFiles(const char *userDoption, const char *progname)
 
        free(configdir);
 
-       /* If timezone is not set, determine what the OS uses */
-       pg_timezone_initialize();
-
        return true;
 }