Suppress attempts to report dropped tables to the stats collector from a
authorTom Lane <[email protected]>
Thu, 30 Mar 2006 22:11:59 +0000 (22:11 +0000)
committerTom Lane <[email protected]>
Thu, 30 Mar 2006 22:11:59 +0000 (22:11 +0000)
startup or recovery process.  Since such a process isn't a real backend,
pgstat.c gets confused.  This accounts for recent reports of strange
"invalid server process ID -1" log messages during crash recovery.
There isn't any point in attempting to make the report, since we'll discard
stats in such scenarios anyhow.

src/backend/storage/smgr/smgr.c

index f268ac89b29dfc3afe9eafc7c3709d982afbb3fa..eeef51171982d878dff50ef881ecc93c61a56d7c 100644 (file)
@@ -470,8 +470,14 @@ smgr_internal_unlink(RelFileNode rnode, int which, bool isTemp, bool isRedo)
         */
        FreeSpaceMapForgetRel(&rnode);
 
-       /* Tell the stats collector to forget it immediately, too. */
-       pgstat_drop_relation(rnode.relNode);
+       /*
+        * Tell the stats collector to forget it immediately, too.  Skip this
+        * in recovery mode, since the stats collector likely isn't running
+        * (and if it is, pgstats.c will get confused because we aren't a real
+        * backend process).
+        */
+       if (!InRecovery)
+               pgstat_drop_relation(rnode.relNode);
 
        /*
         * And delete the physical files.