Re: autovacuum crash due to null pointer

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

Tom Lane wrote:
> There's a fairly interesting crash here:
> http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=jaguar&dt=2008-07-16%2003:00:02
> The buildfarm was nice enough to provide a stack trace at the bottom of
> the page, which shows clearly that autovac tried to pfree a null
> pointer.
>
> 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.

Anyway, I propose this patch in HEAD to close this hole. For 8.3 I'm
thinking in just rearranging the get_*_name calls and adding the goto.
Thoughts?

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?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2008-07-17 15:49:51 Re: autovacuum crash due to null pointer
Previous Message chris 2008-07-17 15:01:16 Re: Postgres-R: primary key patches