Re: autovacuum crash due to null pointer

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: autovacuum crash due to null pointer
Date: 2008-07-17 15:55:35
Message-ID: 18663.1216310135@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2008-07-17 16:01:15 Re: [PATCHES] WITH RECUSIVE patches 0717
Previous Message Alvaro Herrera 2008-07-17 15:49:51 Re: autovacuum crash due to null pointer