Re: autovacuum crash due to null pointer - Mailing list pgsql-hackers

From Tom Lane
Subject Re: autovacuum crash due to null pointer
Date
Msg-id 18663.1216310135@sss.pgh.pa.us
Whole thread Raw
In response to Re: autovacuum crash due to null pointer  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: autovacuum crash due to null pointer  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-hackers
Alvaro Herrera <alvherre@commandprompt.com> writes:
> Tom Lane wrote:
>> What I think happened was that the table that was selected to be
>> autovacuumed got dropped during the setup steps, leading get_rel_name()
>> to return NULL at line 2167.  vacuum() itself would have fallen out
>> silently ...  however, had it errored out, the attempts at error
>> reporting in the PG_CATCH block would have crashed.

> I'm having a hard time reproducing this problem; I added a pg_usleep()
> just before get_rel_name to have the chance to drop the table, but
> strangely enough it doesn't return NULL.  It seems that the cache entry
> is not getting invalidated.  Maybe there's something else that's needed
> to reproduce the crash.

I think cache invals would get noticed at points where we had to open
some relation, so you probably need the sleep somewhere earlier than
that.  Or just throw in an AcceptInvalidationMessages() after the sleep.

> I think there's another hole here: what happens if the table exists when
> get_rel_name is called, but the schema is dropped between that point and
> calling get_namespace_name?  It is pretty unlikely but can it be
> discarded completely?  What should we do in that case?

I think you can just skip the table if any of those three calls return a
null.  That probably means the table/schema/whatever got dropped, and
if for some reason there's a transient failure, it'll get vacuumed next
time anyway.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: autovacuum crash due to null pointer
Next
From: David Fetter
Date:
Subject: Re: [PATCHES] WITH RECUSIVE patches 0717