Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 69500b0

Browse files
committed
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.
1 parent a2899eb commit 69500b0

File tree

1 file changed

+13
-2
lines changed
  • src/backend/storage/ipc

1 file changed

+13
-2
lines changed

src/backend/storage/ipc/ipc.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.97 2007/07/25 19:58:56 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.98 2007/11/04 17:55:15 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -24,6 +24,9 @@
2424
#include <sys/stat.h>
2525

2626
#include "miscadmin.h"
27+
#ifdef PROFILE_PID_DIR
28+
#include "postmaster/autovacuum.h"
29+
#endif
2730
#include "storage/ipc.h"
2831

2932

@@ -126,14 +129,22 @@ proc_exit(int code)
126129
* $PGDATA/gprof/8845/gmon.out
127130
* ...
128131
*
132+
* To avoid undesirable disk space bloat, autovacuum workers are
133+
* discriminated against: all their gmon.out files go into the same
134+
* subdirectory. Without this, an installation that is "just sitting
135+
* there" nonetheless eats megabytes of disk space every few seconds.
136+
*
129137
* Note that we do this here instead of in an on_proc_exit()
130138
* callback because we want to ensure that this code executes
131139
* last - we don't want to interfere with any other on_proc_exit()
132140
* callback.
133141
*/
134142
char gprofDirName[32];
135143

136-
snprintf(gprofDirName, 32, "gprof/%d", (int) getpid());
144+
if (IsAutoVacuumWorkerProcess())
145+
snprintf(gprofDirName, 32, "gprof/avworker");
146+
else
147+
snprintf(gprofDirName, 32, "gprof/%d", (int) getpid());
137148

138149
mkdir("gprof", 0777);
139150
mkdir(gprofDirName, 0777);

0 commit comments

Comments
 (0)