Skip to content

Commit be72b9c

Browse files
committed
Fix autovacuum work item error handling
In autovacuum's "work item" processing, a few strings were allocated in the current transaction's memory context, which goes away during error handling; if an error happened during execution of the work item, the pfree() calls to clean up afterwards would try to release already-released memory, possibly leading to a crash. In branch master, this was already fixed by commit 335f3d0, so backpatch that to REL_10_STABLE to fix the problem there too. As a secondary problem, verify that the autovacuum worker is connected to the right database for each work item; otherwise some items would be discarded by workers in other databases. Reported-by: Justin Pryzby Discussion: https://postgr.es/m/20171014035732.GB31726@telsasoft.com
1 parent 77954f9 commit be72b9c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/postmaster/autovacuum.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,6 +2531,8 @@ do_autovacuum(void)
25312531
continue;
25322532
if (workitem->avw_active)
25332533
continue;
2534+
if (workitem->avw_database != MyDatabaseId)
2535+
continue;
25342536

25352537
/* claim this one, and release lock while performing it */
25362538
workitem->avw_active = true;
@@ -2606,9 +2608,7 @@ perform_work_item(AutoVacuumWorkItem *workitem)
26062608
/*
26072609
* Save the relation name for a possible error message, to avoid a catalog
26082610
* lookup in case of an error. If any of these return NULL, then the
2609-
* relation has been dropped since last we checked; skip it. Note: they
2610-
* must live in a long-lived memory context because we call vacuum and
2611-
* analyze in different transactions.
2611+
* relation has been dropped since last we checked; skip it.
26122612
*/
26132613
Assert(CurrentMemoryContext == AutovacMemCxt);
26142614

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy