Re: "invalid memory alloc request size <n>" in deferred trigger causes transaction to fail, but the backend keeps running

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl>
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: "invalid memory alloc request size <n>" in deferred trigger causes transaction to fail, but the backend keeps running
Date: 2004-12-06 18:22:35
Message-ID: 4896.1102357355@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl> writes:
> Looking forward to your assesment.

Looks like the problem is associated with DEFERRED AFTER triggers: we
don't normally set a snapshot for TransactionStmt commands, including
COMMIT, but there needs to be a snapshot set when running trigger
functions. The attached patch fixes the test case you sent; can you
try it against your other problem?

regards, tom lane

*** src/backend/commands/trigger.c.orig Sun Nov 14 14:37:05 2004
--- src/backend/commands/trigger.c Mon Dec 6 13:20:43 2004
***************
*** 2365,2370 ****
--- 2365,2378 ----
Assert(afterTriggers->query_depth == -1);

/*
+ * If there are any triggers to fire, make sure we have set a snapshot
+ * for them to use. (Since PortalRunUtility doesn't set a snap for
+ * COMMIT, we can't assume ActiveSnapshot is valid on entry.)
+ */
+ if (afterTriggers->events.head != NULL)
+ ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
+
+ /*
* Run all the remaining triggers. Loop until they are all gone,
* just in case some trigger queues more for us to do.
*/

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-12-06 18:50:32 Re: serial drop error
Previous Message Ed L. 2004-12-06 17:49:47 Re: serial drop error