diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2009-01-20 12:17:23 +0000 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2009-01-20 12:17:23 +0000 |
commit | 7b4460885f2f651e36099124852aa6c1a9f66f5b (patch) | |
tree | a8987f6e0a22b11848fce26b489c0e459bbff5a6 | |
parent | d7adf1b3420f40e32c5b8fdc5f9c101eb7711baf (diff) | |
download | postgresql-7b4460885f2f651e36099124852aa6c1a9f66f5b.tar.gz postgresql-7b4460885f2f651e36099124852aa6c1a9f66f5b.zip |
Fix erroneous memory context switch in autovacuum, which was returning to a
context long after it had been destroyed.
Per problem report from Justin Pasher. Patch by Tom Lane and me.
8.3 and later do not have this bug, because this code has been restructured for
unrelated reasons. In 8.2 it does not manifest as a crash, but it still seems
safer fixing it nonetheless.
-rw-r--r-- | src/backend/postmaster/autovacuum.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index f17b3905d32..be395aec14e 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.29.2.1 2008/01/17 23:47:04 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.29.2.2 2009/01/20 12:17:23 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -883,13 +883,12 @@ autovacuum_do_vac_analyze(Oid relid, bool dovacuum, bool doanalyze, int freeze_min_age) { VacuumStmt *vacstmt; - MemoryContext old_cxt; /* * The node must survive transaction boundaries, so make sure we create it * in a long-lived context */ - old_cxt = MemoryContextSwitchTo(AutovacMemCxt); + MemoryContextSwitchTo(AutovacMemCxt); vacstmt = makeNode(VacuumStmt); @@ -915,7 +914,9 @@ autovacuum_do_vac_analyze(Oid relid, bool dovacuum, bool doanalyze, vacuum(vacstmt, list_make1_oid(relid)); pfree(vacstmt); - MemoryContextSwitchTo(old_cxt); + + /* Make sure we end up pointing to the long-lived context at exit */ + MemoryContextSwitchTo(AutovacMemCxt); } /* |