mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
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 335f3d04e4
, 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
This commit is contained in:
@ -2531,6 +2531,8 @@ deleted:
|
|||||||
continue;
|
continue;
|
||||||
if (workitem->avw_active)
|
if (workitem->avw_active)
|
||||||
continue;
|
continue;
|
||||||
|
if (workitem->avw_database != MyDatabaseId)
|
||||||
|
continue;
|
||||||
|
|
||||||
/* claim this one, and release lock while performing it */
|
/* claim this one, and release lock while performing it */
|
||||||
workitem->avw_active = true;
|
workitem->avw_active = true;
|
||||||
@ -2606,9 +2608,7 @@ perform_work_item(AutoVacuumWorkItem *workitem)
|
|||||||
/*
|
/*
|
||||||
* Save the relation name for a possible error message, to avoid a catalog
|
* Save the relation name for a possible error message, to avoid a catalog
|
||||||
* lookup in case of an error. If any of these return NULL, then the
|
* lookup in case of an error. If any of these return NULL, then the
|
||||||
* relation has been dropped since last we checked; skip it. Note: they
|
* relation has been dropped since last we checked; skip it.
|
||||||
* must live in a long-lived memory context because we call vacuum and
|
|
||||||
* analyze in different transactions.
|
|
||||||
*/
|
*/
|
||||||
Assert(CurrentMemoryContext == AutovacMemCxt);
|
Assert(CurrentMemoryContext == AutovacMemCxt);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user