Avoid crashing when a table is deleted while we're on the process of checking
it. This is a stripped down version of the patch applied to HEAD. Per report from Tom Lane based on buildfarm evidence.
This commit is contained in:
parent
6dafb5b4ae
commit
f1583ed591
@ -55,7 +55,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.71.2.3 2008/03/14 23:49:33 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.71.2.4 2008/07/17 21:02:41 alvherre Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -2098,13 +2098,16 @@ do_autovacuum(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Save the relation name for a possible error message, to avoid a
|
* Save the relation name for a possible error message, to avoid a
|
||||||
* catalog lookup in case of an error. Note: they must live in a
|
* catalog lookup in case of an error. If any of these return NULL,
|
||||||
* long-lived memory context because we call vacuum and analyze in
|
* then the relation has been dropped since last we checked; skip it.
|
||||||
* different transactions.
|
* Note: they must live in a long-lived memory context because we call
|
||||||
|
* vacuum and analyze in different transactions.
|
||||||
*/
|
*/
|
||||||
datname = get_database_name(MyDatabaseId);
|
datname = get_database_name(MyDatabaseId);
|
||||||
nspname = get_namespace_name(get_rel_namespace(tab->at_relid));
|
nspname = get_namespace_name(get_rel_namespace(tab->at_relid));
|
||||||
relname = get_rel_name(tab->at_relid);
|
relname = get_rel_name(tab->at_relid);
|
||||||
|
if (!datname || !nspname || !relname)
|
||||||
|
goto deleted;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We will abort vacuuming the current table if something errors out,
|
* We will abort vacuuming the current table if something errors out,
|
||||||
@ -2158,11 +2161,15 @@ do_autovacuum(void)
|
|||||||
|
|
||||||
/* the PGPROC flags are reset at the next end of transaction */
|
/* the PGPROC flags are reset at the next end of transaction */
|
||||||
|
|
||||||
|
deleted:
|
||||||
/* be tidy */
|
/* be tidy */
|
||||||
pfree(tab);
|
pfree(tab);
|
||||||
pfree(datname);
|
if (datname)
|
||||||
pfree(nspname);
|
pfree(datname);
|
||||||
pfree(relname);
|
if (nspname)
|
||||||
|
pfree(nspname);
|
||||||
|
if (relname)
|
||||||
|
pfree(relname);
|
||||||
|
|
||||||
/* remove my info from shared memory */
|
/* remove my info from shared memory */
|
||||||
LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE);
|
LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user