Re: [sqlsmith] Failed assertion in parallel worker (ExecInitSubPlan) - Mailing list pgsql-hackers

From Dilip Kumar
Subject Re: [sqlsmith] Failed assertion in parallel worker (ExecInitSubPlan)
Date
Msg-id CAFiTN-vzg5BkK6kAh3OMhvgRu-uJvkjz47ybtopMAfGJp=zWqA@mail.gmail.com
Whole thread Raw
In response to Re: [sqlsmith] Failed assertion in parallel worker (ExecInitSubPlan)  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: [sqlsmith] Failed assertion in parallel worker (ExecInitSubPlan)  (Andreas Seltenreich <seltenreich@gmx.de>)
List pgsql-hackers

On Fri, May 13, 2016 at 10:31 AM, Amit Kapila <amit.kapila16@gmail.com> wrote:
Here I want to ask base rels which are plain rels?

It might be that I am missing something, but if we debug the serial plan for original query [1] for which this issue is reported, we have noticed that PlaceHolderVars that contain subplans are added to base rels for which RTE kind is (RTE_RELATION).


[1] - select ref_68.is_trigger_deletable as c0, (select d from

Finally, I could reproduce this issue, with just three tables.

If targetlist of top query has subquery references and if subquery is part of OUTER join, then while pulling up the subquery,
it will create PlaceHolderVar, which will have expressions.

After applying prohibit_parallel_clause_below_rel_v1.patch, it is not selecting parallel plan.
So now its clear that because of sub query pullup, we may get expression in targetlist while creating single table path list. So we need to avoid parallel plan if it contains expression.

Below is my test:
--------------------------

postgres=# CREATE TABLE t1(c1, c2) AS SELECT g, repeat('x', 5) FROM
postgres-# generate_series(1, 10000000) g;

SELECT 10000000
postgres=# 
postgres=# CREATE TABLE t2(c1, c2) AS SELECT g, repeat('x', 5) FROM
postgres-# generate_series(1, 1000000) g;
SELECT 1000000
postgres=# CREATE TABLE t3(c1, c2) AS SELECT g, repeat('x', 5) FROM
generate_series(1, 1000000) g;
SELECT 1000000
postgres=# analyze t1;
ANALYZE
postgres=# analyze t2;
ANALYZE
postgres=# analyze t3;
ANALYZE

postgres=# explain select t1.c1, y.x from t1 left join (select (select t3.c1 from t3 where t3.c1=t2.c1) as x from t2)y on (y.x=t1.c1);
                                     QUERY PLAN                                      
-------------------------------------------------------------------------------------
 Hash Right Join  (cost=319113.85..96991333895.85 rows=9999860 width=8)
   Hash Cond: ((SubPlan 2) = t1.c1)
   ->  Gather  (cost=1000.00..7460943906.00 rows=1000000 width=8)
         Workers Planned: 2
         ->  Parallel Seq Scan on t2  (cost=0.00..7460842906.00 rows=416667 width=8)
               SubPlan 1
                 ->  Seq Scan on t3  (cost=0.00..17906.00 rows=1 width=4)
                       Filter: (c1 = t2.c1)
   ->  Hash  (cost=154053.60..154053.60 rows=9999860 width=4)
         ->  Seq Scan on t1  (cost=0.00..154053.60 rows=9999860 width=4)
   SubPlan 2
     ->  Seq Scan on t3 t3_1  (cost=0.00..17906.00 rows=1 width=4)
           Filter: (c1 = t2.c1)
(13 rows)

postgres=# select t1.c1, y.x from t1 left join (select (select t3.c1 from t3 where t3.c1=t2.c1) as x from t2)y on (y.x=t1.c1);
LOG:  worker process: parallel worker for PID 109446 (PID 109483) was terminated by signal 11: Segmentation fault
LOG:  terminating any other active server processes
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.


--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Perf Benchmarking and regression.
Next
From: Andreas Seltenreich
Date:
Subject: Just-in-time compiling things (was: asynchronous and vectorized execution)