Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit945ba50

Browse files
committed
Fix a memory leak in the autovacuum launcher code. Noted by Darcy Buskermolen,
who reported it privately to me.
1 parent6889303 commit945ba50

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.57 2007/09/11 17:15:33 tgl Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.58 2007/09/12 22:14:59 alvherre Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -1038,6 +1038,9 @@ do_start_worker(void)
10381038
avw_dbase*avdb;
10391039
TimestampTzcurrent_time;
10401040
boolskipit= false;
1041+
Oidretval=InvalidOid;
1042+
MemoryContexttmpcxt,
1043+
oldcxt;
10411044

10421045
/* return quickly when there are no free workers */
10431046
LWLockAcquire(AutovacuumLock,LW_SHARED);
@@ -1048,6 +1051,17 @@ do_start_worker(void)
10481051
}
10491052
LWLockRelease(AutovacuumLock);
10501053

1054+
/*
1055+
* Create and switch to a temporary context to avoid leaking the memory
1056+
* allocated for the database list.
1057+
*/
1058+
tmpcxt=AllocSetContextCreate(CurrentMemoryContext,
1059+
"Start worker tmp cxt",
1060+
ALLOCSET_DEFAULT_MINSIZE,
1061+
ALLOCSET_DEFAULT_INITSIZE,
1062+
ALLOCSET_DEFAULT_MAXSIZE);
1063+
oldcxt=MemoryContextSwitchTo(tmpcxt);
1064+
10511065
/* use fresh stats */
10521066
pgstat_clear_snapshot();
10531067

@@ -1186,7 +1200,7 @@ do_start_worker(void)
11861200

11871201
SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_WORKER);
11881202

1189-
returnavdb->adw_datid;
1203+
retval=avdb->adw_datid;
11901204
}
11911205
elseif (skipit)
11921206
{
@@ -1197,7 +1211,10 @@ do_start_worker(void)
11971211
rebuild_database_list(InvalidOid);
11981212
}
11991213

1200-
returnInvalidOid;
1214+
MemoryContextSwitchTo(oldcxt);
1215+
MemoryContextDelete(tmpcxt);
1216+
1217+
returnretval;
12011218
}
12021219

12031220
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp