Re: Autovacuum daemon terminated by signal 11 - Mailing list pgsql-general

From Tom Lane
Subject Re: Autovacuum daemon terminated by signal 11
Date
Msg-id 12265.1232207394@sss.pgh.pa.us
Whole thread Raw
In response to Re: Autovacuum daemon terminated by signal 11  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Autovacuum daemon terminated by signal 11
Re: Autovacuum daemon terminated by signal 11
List pgsql-general
Alvaro Herrera <alvherre@commandprompt.com> writes:
> 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.

Yeah, there could be some platform dependency involved.  I'm guessing
different structs that happen to fall into the same palloc size category
on one platform but not another.

Anyway, it happens consistently on my HP box.  I find that your proposed
patch fixes it, but makes the "normal" path crash :-( --- the loop in
do_autovacuum has to be executed in AutovacMemCxt, because it creates an
Oid List that gets passed to vacuum() and had better not be in a
transaction-lifetime context.  The attached modified patch works for me.

            regards, tom lane

Index: autovacuum.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/postmaster/autovacuum.c,v
retrieving revision 1.5.2.8
diff -c -r1.5.2.8 autovacuum.c
*** autovacuum.c    17 Jan 2008 23:47:07 -0000    1.5.2.8
--- autovacuum.c    17 Jan 2009 15:31:05 -0000
***************
*** 925,937 ****
                            bool freeze)
  {
      VacuumStmt *vacstmt;
-     MemoryContext old_cxt;

      /*
       * The node must survive transaction boundaries, so make sure we create it
       * in a long-lived context
       */
!     old_cxt = MemoryContextSwitchTo(AutovacMemCxt);

      vacstmt = makeNode(VacuumStmt);

--- 925,936 ----
                            bool freeze)
  {
      VacuumStmt *vacstmt;

      /*
       * The node must survive transaction boundaries, so make sure we create it
       * in a long-lived context
       */
!     MemoryContextSwitchTo(AutovacMemCxt);

      vacstmt = makeNode(VacuumStmt);

***************
*** 957,963 ****
      vacuum(vacstmt, relids);

      pfree(vacstmt);
!     MemoryContextSwitchTo(old_cxt);
  }

  /*
--- 956,964 ----
      vacuum(vacstmt, relids);

      pfree(vacstmt);
!
!     /* Make sure we end up pointing to the long-lived context at exit */
!     MemoryContextSwitchTo(AutovacMemCxt);
  }

  /*

pgsql-general by date:

Previous
From: johnf
Date:
Subject: Re: executing a sql script
Next
From: "Joshua D. Drake"
Date:
Subject: Re: executing a sql script