Re: ERROR: cannot start subtransactions during a parallel operation

From: Mai Peng <maily(dot)peng(at)webedia-group(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ERROR: cannot start subtransactions during a parallel operation
Date: 2018-07-11 23:02:30
Message-ID: 7772057A-8318-49AA-A6EB-221C94A871D6@webedia-group.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,
Sorry for the late reply.
I could handle the pb by transforming my function check ( with an exception ) by a simple sql immutable function.
Function before
CREATE OR REPLACE FUNCTION test_id(ltree[])
RETURNS boolean AS
$BODY$
DECLARE
id public.ltree;
BEGIN
FOR id IN SELECT unnest($1) LOOP
PERFORMl id::id;
IF () THEN
RETURN FALSE;
END IF;
END LOOP;
RETURN TRUE;
EXCEPTION
WHEN OTHERS THEN RETURN FALSE;
END;
$BODY$
LANGUAGE plpgsql VOLATILE;

AFTER
CREATE OR REPLACE FUNCTION test_Id(ltree[])
RETURNS boolean AS
$BODY$
SELECT NOT EXISTS (
SELECT 1
FROM unnest ($1) id
WHERE id<>id::id
)
$BODY$
LANGUAGE sql IMMUTABLE STRICT;

> Le 1 juil. 2018 à 11:02, Mai Peng <maily(dot)peng(at)webedia-group(dot)com> a écrit :
>
> Hello, how could I relax the subtransaction restriction, I used the Parallel Unsafe option, but still have the same issue.
> Rgds.
>
> Le ven. 29 juin 2018 20:47, Andres Freund <andres(at)anarazel(dot)de <mailto:andres(at)anarazel(dot)de>> a écrit :
> Hi,
>
> On 2018-06-29 20:37:23 +0200, Tomas Vondra wrote:
> > My guess is that it's a PL/pgSQL function with an EXCEPTION block, and
> > there's no easy way to "fix" that.
>
> Obviously not going to immediately help the OP, but I do think we should
> be able to relax the subtransaction restriction around parallelism
> without too much work. Can't allow xids to be assigned, but that's
> probably ok for a lot of exception handling cases.
>
> Greetings,
>
> Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2018-07-11 23:08:41 Re: [HACKERS] autovacuum can't keep up, bloat just continues to rise
Previous Message Alvaro Herrera 2018-07-11 22:59:16 Re: TRUNCATE tables referenced by FKs on partitioned tables