Commit 69500b05 authored by Tom Lane's avatar Tom Lane

Prevent continuing disk-space bloat when profiling (with PROFILE_PID_DIR

enabled) and autovacuum is on.  Since there will be a steady stream of autovac
worker processes exiting and dropping gmon.out files, allowing them to make
separate subdirectories results in serious bloat; and it seems unlikely that
anyone will care about those profiles anyway.  Limit the damage by forcing all
autovac workers to dump in one subdirectory, PGDATA/gprof/avworker/.

Per report from Jšrg Beyer and subsequent discussion.
parent a2899ebd
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.97 2007/07/25 19:58:56 tgl Exp $ * $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.98 2007/11/04 17:55:15 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "miscadmin.h" #include "miscadmin.h"
#ifdef PROFILE_PID_DIR
#include "postmaster/autovacuum.h"
#endif
#include "storage/ipc.h" #include "storage/ipc.h"
...@@ -126,6 +129,11 @@ proc_exit(int code) ...@@ -126,6 +129,11 @@ proc_exit(int code)
* $PGDATA/gprof/8845/gmon.out * $PGDATA/gprof/8845/gmon.out
* ... * ...
* *
* To avoid undesirable disk space bloat, autovacuum workers are
* discriminated against: all their gmon.out files go into the same
* subdirectory. Without this, an installation that is "just sitting
* there" nonetheless eats megabytes of disk space every few seconds.
*
* Note that we do this here instead of in an on_proc_exit() * Note that we do this here instead of in an on_proc_exit()
* callback because we want to ensure that this code executes * callback because we want to ensure that this code executes
* last - we don't want to interfere with any other on_proc_exit() * last - we don't want to interfere with any other on_proc_exit()
...@@ -133,6 +141,9 @@ proc_exit(int code) ...@@ -133,6 +141,9 @@ proc_exit(int code)
*/ */
char gprofDirName[32]; char gprofDirName[32];
if (IsAutoVacuumWorkerProcess())
snprintf(gprofDirName, 32, "gprof/avworker");
else
snprintf(gprofDirName, 32, "gprof/%d", (int) getpid()); snprintf(gprofDirName, 32, "gprof/%d", (int) getpid());
mkdir("gprof", 0777); mkdir("gprof", 0777);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment