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

Commit4873c96

Browse files
committed
Fix inappropriately-timed memory context switch in autovacuum_do_vac_analyze.
This accidentally failed to fail before 8.3, because the context we wereswitching back to was long-lived anyway; but it sure looks risky as can benow. Well spotted by Pavan Deolasee.
1 parent4844529 commit4873c96

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 12 additions & 10 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.73 2008/03/1417:25:58 alvherre Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.74 2008/03/1423:49:28 tgl Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -2602,17 +2602,12 @@ autovacuum_do_vac_analyze(Oid relid, bool dovacuum, bool doanalyze,
26022602
BufferAccessStrategybstrategy)
26032603
{
26042604
VacuumStmtvacstmt;
2605+
List*relids;
26052606
MemoryContextold_cxt;
26062607

2608+
/* Set up command parameters --- use a local variable instead of palloc */
26072609
MemSet(&vacstmt,0,sizeof(vacstmt));
26082610

2609-
/*
2610-
* The list must survive transaction boundaries, so make sure we create it
2611-
* in a long-lived context
2612-
*/
2613-
old_cxt=MemoryContextSwitchTo(AutovacMemCxt);
2614-
2615-
/* Set up command parameters */
26162611
vacstmt.type=T_VacuumStmt;
26172612
vacstmt.vacuum=dovacuum;
26182613
vacstmt.full= false;
@@ -2622,11 +2617,18 @@ autovacuum_do_vac_analyze(Oid relid, bool dovacuum, bool doanalyze,
26222617
vacstmt.relation=NULL;/* not used since we pass a relids list */
26232618
vacstmt.va_cols=NIL;
26242619

2620+
/*
2621+
* The list must survive transaction boundaries, so make sure we create it
2622+
* in a long-lived context
2623+
*/
2624+
old_cxt=MemoryContextSwitchTo(AutovacMemCxt);
2625+
relids=list_make1_oid(relid);
2626+
MemoryContextSwitchTo(old_cxt);
2627+
26252628
/* Let pgstat know what we're doing */
26262629
autovac_report_activity(&vacstmt,relid);
26272630

2628-
vacuum(&vacstmt,list_make1_oid(relid),bstrategy,for_wraparound, true);
2629-
MemoryContextSwitchTo(old_cxt);
2631+
vacuum(&vacstmt,relids,bstrategy,for_wraparound, true);
26302632
}
26312633

26322634
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp