Re: BUG #5622: Query failed: server closed the connection unexpectedly - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5622: Query failed: server closed the connection unexpectedly
Date
Msg-id 1063.1282231198@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #5622: Query failed: server closed the connection unexpectedly  (Thue Janus Kristensen <thuejk@gmail.com>)
Responses Re: BUG #5622: Query failed: server closed the connection unexpectedly  (Thue Janus Kristensen <thuejk@gmail.com>)
List pgsql-bugs
Thue Janus Kristensen <thuejk@gmail.com> writes:
> I finally succeeded in creating a test case, after much experimentation.
> Running the attached sql crashes my postgresql server 100% of the time.

Cute problem.  The attached fix cures it for me; would you see if it
solves your original case too?

            regards, tom lane

Index: src/backend/commands/trigger.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/commands/trigger.c,v
retrieving revision 1.248.2.2
diff -c -r1.248.2.2 trigger.c
*** src/backend/commands/trigger.c    24 Jan 2010 21:49:31 -0000    1.248.2.2
--- src/backend/commands/trigger.c    19 Aug 2010 15:14:06 -0000
***************
*** 2534,2539 ****
--- 2534,2540 ----
          else
              events->tail->next = chunk;
          events->tail = chunk;
+         /* events->tailfree is now out of sync, but we'll fix it below */
      }

      /*
***************
*** 2935,2940 ****
--- 2936,2950 ----
          {
              chunk->freeptr = CHUNK_DATA_START(chunk);
              chunk->endfree = chunk->endptr;
+
+             /*
+              * If it's last chunk, must sync event list's tailfree too.  Note
+              * that delete_ok must NOT be passed as true if there could be
+              * stacked AfterTriggerEventList values pointing at this event
+              * list, since we'd fail to fix their copies of tailfree.
+              */
+             if (chunk == events->tail)
+                 events->tailfree = chunk->freeptr;
          }
      }


pgsql-bugs by date:

Previous
From: Jens Wilke
Date:
Subject: Re: BUG #5623: xml2 and uuid-ossp contribs fail to compile
Next
From: Tom Lane
Date:
Subject: Re: BUG #5626: Parallel pg_restore fails with "tuple concurrently updated"