]> granicus.if.org Git - postgresql/commitdiff
Move postmaster's RemovePgTempFiles call to a less randomly chosen place.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 22 May 2012 02:50:30 +0000 (22:50 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 22 May 2012 02:50:30 +0000 (22:50 -0400)
There is no reason to do this as early as possible in postmaster startup,
and good reason not to do it until we have completely created the
postmaster's lock file, namely that it might contribute to pg_ctl thinking
that postmaster startup has timed out.  (This would require a rather
unusual amount of time to be spent scanning temp file directories, but we
have at least one field report of it happening reproducibly.)

Back-patch to 9.1.  Before that, pg_ctl didn't wait for additional info to
be added to the lock file, so it wasn't a problem.

Note that this is not a complete fix to the slow-start issue in 9.1,
because we still had identify_system_timezone being run during postmaster
start in 9.1.  But that's at least a reasonably well-defined delay, with
an easy workaround if needed, whereas the temp-files scan is not so
predictable and cannot be avoided.

src/backend/postmaster/postmaster.c

index dd7dd5560faf03443df89f9216a31f2d51ad183f..e400f0a8e15e8d7e02b1d3f5724940c1dd323bf6 100644 (file)
@@ -826,12 +826,6 @@ PostmasterMain(int argc, char *argv[])
         */
        process_shared_preload_libraries();
 
-       /*
-        * Remove old temporary files.  At this point there can be no other
-        * Postgres processes running in this directory, so this should be safe.
-        */
-       RemovePgTempFiles();
-
        /*
         * Establish input sockets.
         */
@@ -1099,6 +1093,12 @@ PostmasterMain(int argc, char *argv[])
        }
        load_ident();
 
+       /*
+        * Remove old temporary files.  At this point there can be no other
+        * Postgres processes running in this directory, so this should be safe.
+        */
+       RemovePgTempFiles();
+
        /*
         * Remember postmaster startup time
         */