Re: Autovacuum daemon terminated by signal 11

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Justin Pasher <justinp(at)newmediagateway(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Autovacuum daemon terminated by signal 11
Date: 2009-01-17 04:14:33
Message-ID: 20090117041433.GI12449@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Tom Lane wrote:

> What is happening is that autovacuum_do_vac_analyze contains
>
> old_cxt = MemoryContextSwitchTo(AutovacMemCxt);
> ...
> vacuum(vacstmt, relids);
> ...
> MemoryContextSwitchTo(old_cxt);
>
> and at the time it is called by process_whole_db, CurrentMemoryContext
> points at TopTransactionContext. Which gets destroyed because vacuum()
> internally finishes that transaction and starts a new one. When we
> come out of vacuum(), CurrentMemoryContext again points at
> TopTransactionContext, but *its not the same one*. The closing
> MemoryContextSwitchTo is installing a stale pointer, which then remains
> active into CommitTransaction. It's a wonder this code ever works.

Hmm, in retrospect this is pretty obviously buggy. I can't say that
it's that easy for me to reproduce it though; I definitely can't make it
crash. Maybe by sheer luck, the new TopTransactionContext pointer
points to the same memory area that the old was stored in.

I think this patch should fix it. Justin, would you try it and report
back? I would commit it right away since it seems simple enough, but
since I can't reproduce the crash, I prefer external confirmation first
:-)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment Content-Type Size
autovacuum-mcxt-81.patch text/x-diff 1.4 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vincent Predoehl 2009-01-17 04:32:56 accessing user table structures from SQL
Previous Message Leif Jensen 2009-01-17 02:52:36 Re: Slave server: FATAL: incorrect checksum in control file

Browse pgsql-hackers by date

  From Date Subject
Next Message KaiGai Kohei 2009-01-17 04:21:46 Status Report on SE-PostgreSQL
Previous Message Tom Lane 2009-01-17 00:58:50 Re: WIP: Automatic view update rules