Hello,

This crash was reproduced on our environment also.
It looks to me adjust_child_relids_multilevel() didn't expect a case
when supplied 'relids'
(partially) indicate normal and non-partitioned relation.
It tries to build a new 'parent_relids' that is a set of
appinfo->parent_relid related to the
supplied 'child_relids'. However, bits in child_relids that indicate
normal relations are
unintentionally dropped here. Then, adjust_child_relids_multilevel()
goes to an infinite
recursion until stack limitation.

The attached v2 fixed the problem, and regression test finished correctly.

Best regards,

2019年12月1日(日) 12:24 Michael Paquier <mich...@paquier.xyz>:
>
> On Sat, Aug 24, 2019 at 05:33:01PM +0900, Kohei KaiGai wrote:
> > On the other hands, it eventually consumes almost equivalent amount
> > of memory to load the inner relations, if no leafs are pruned, and if we
> > could extend the Hash-node to share the hash-table with sibling
> > join-nodess.
>
> The patch crashes when running the regression tests, per the report of
> the automatic patch tester.  Could you look at that?  I have moved the
> patch to nexf CF, waiting on author.
> --
> Michael



-- 
HeteroDB, Inc / The PG-Strom Project
KaiGai Kohei <kai...@heterodb.com>
#12912 0x00000000006f9471 in adjust_child_relids_multilevel (
    root=root@entry=0x2115240, relids=relids@entry=0x2106df8,
    child_relids=child_relids@entry=0x0,
    top_parent_relids=top_parent_relids@entry=0x20afd88) at appendinfo.c:602
#12913 0x00000000006f9471 in adjust_child_relids_multilevel (
    root=root@entry=0x2115240, relids=relids@entry=0x2106df8,
    child_relids=child_relids@entry=0x0,
    top_parent_relids=top_parent_relids@entry=0x20afd88) at appendinfo.c:602
#12914 0x00000000006f9471 in adjust_child_relids_multilevel (
    root=root@entry=0x2115240, relids=relids@entry=0x2106df8,
    child_relids=child_relids@entry=0x0,
    top_parent_relids=top_parent_relids@entry=0x20afd88) at appendinfo.c:602
#12915 0x00000000006f9471 in adjust_child_relids_multilevel (
    root=root@entry=0x2115240, relids=relids@entry=0x2106df8,
    child_relids=child_relids@entry=0x20b0bb8,
    top_parent_relids=top_parent_relids@entry=0x20afd88) at appendinfo.c:602
#12916 0x00000000006f9471 in adjust_child_relids_multilevel (
    root=root@entry=0x2115240, relids=relids@entry=0x2106df8,
    child_relids=child_relids@entry=0x20af9d8,
    top_parent_relids=top_parent_relids@entry=0x20afd88) at appendinfo.c:602
#12917 0x00000000006c9805 in add_child_join_rel_equivalences (
    root=root@entry=0x2115240, nappinfos=1, appinfos=appinfos@entry=0x20afdb0,
    parent_joinrel=parent_joinrel@entry=0x20ae420,
    child_joinrel=child_joinrel@entry=0x20aef10) at equivclass.c:2458
#12918 0x000000000070bc07 in build_child_join_rel (root=root@entry=0x2115240,
    outer_rel=outer_rel@entry=0x210a318, inner_rel=inner_rel@entry=0x21051a0,
    parent_joinrel=parent_joinrel@entry=0x20ae420,
    restrictlist=restrictlist@entry=0x20afcd8, sjinfo=sjinfo@entry=0x20afa00,
    jointype=JOIN_INNER) at relnode.c:896
#12919 0x00000000006d2dcf in extract_asymmetric_partitionwise_subjoin (
    append_path=0x20a4000, extra=0x7ffea461c710, extra=0x7ffea461c710,
    jointype=JOIN_INNER, inner_rel=0x21051a0, joinrel=0x20ae420,
    root=0x2115240) at joinrels.c:1573
#12920 try_asymmetric_partitionwise_join (root=root@entry=0x2115240,
    joinrel=joinrel@entry=0x20ae420, outer_rel=outer_rel@entry=0x207cce0,
    inner_rel=inner_rel@entry=0x21051a0, jointype=jointype@entry=JOIN_INNER,
    extra=extra@entry=0x7ffea461c710) at joinrels.c:1641
#12921 0x00000000006cf296 in add_paths_to_joinrel (root=root@entry=0x2115240,
    joinrel=joinrel@entry=0x20ae420, outerrel=outerrel@entry=0x207cce0,
    innerrel=innerrel@entry=0x21051a0, jointype=jointype@entry=JOIN_INNER,
    sjinfo=sjinfo@entry=0x7ffea461c8c0, restrictlist=0x20ae898)
    at joinpath.c:333
#12922 0x00000000006d1a3a in populate_joinrel_with_paths (root=0x2115240,
    rel1=0x207cce0, rel2=0x21051a0, joinrel=0x20ae420, sjinfo=0x7ffea461c8c0,
    restrictlist=0x20ae898) at joinrels.c:804
#12923 0x00000000006d2505 in make_join_rel (root=root@entry=0x2115240,
    rel1=rel1@entry=0x207cce0, rel2=rel2@entry=0x21051a0) at joinrels.c:757
#12924 0x00000000006d278d in make_rels_by_clause_joins (
    other_rels=<optimized out>, other_rels_list=0x20ae390, old_rel=0x207cce0,
    root=0x2115240) at joinrels.c:309
#12925 join_search_one_level (root=root@entry=0x2115240, level=level@entry=2)
    at joinrels.c:120
#12926 0x00000000006bdd4b in standard_join_search (root=0x2115240,
    levels_needed=3, initial_rels=<optimized out>) at allpaths.c:2879
#12927 0x00000000006be1c4 in make_one_rel (root=root@entry=0x2115240,
    joinlist=joinlist@entry=0x2106b80) at allpaths.c:227
#12928 0x00000000006e1cdb in query_planner (root=root@entry=0x2115240,
    qp_callback=qp_callback@entry=0x6e22b0 <standard_qp_callback>,
    qp_extra=qp_extra@entry=0x7ffea461cb60) at planmain.c:269
#12929 0x00000000006e6962 in grouping_planner (root=<optimized out>,
    inheritance_update=false, tuple_fraction=<optimized out>) at planner.c:2059
#12930 0x00000000006e9952 in subquery_planner (glob=glob@entry=0x2114e78,
    parse=parse@entry=0x2085558, parent_root=parent_root@entry=0x0,
    hasRecursion=hasRecursion@entry=false,
    tuple_fraction=tuple_fraction@entry=0) at planner.c:1016
#12931 0x00000000006eaaaf in standard_planner (parse=0x2085558,
    cursorOptions=256, boundParams=<optimized out>) at planner.c:406
#12932 0x00000000007aa059 in pg_plan_query (
    querytree=querytree@entry=0x2085558,
    cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0)
    at postgres.c:874
#12933 0x00000000005d7433 in ExplainOneQuery (query=0x2085558,
    cursorOptions=256, into=0x0, es=0x207cc10,
    queryString=0x1fa95b0 "EXPLAIN (COSTS OFF)\nSELECT t1.a, ss.t2a, ss.t2c 
FROM prt1 t1 LEFT JOIN LATERAL\n\t\t\t  (SELECT t2.a AS t2a, t3.a AS t3a, t2.b 
t2b, t2.c t2c, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = 
t3."...,

    params=0x0, queryEnv=0x0) at explain.c:367
#12934 0x00000000005d7a5b in ExplainQuery (pstate=pstate@entry=0x207cab0,
    stmt=stmt@entry=0x206d918,
    queryString=queryString@entry=0x1fa95b0 "EXPLAIN (COSTS OFF)\nSELECT t1.a, 
ss.t2a, ss.t2c FROM prt1 t1 LEFT JOIN LATERAL\n\t\t\t  (SELECT t2.a AS t2a, 
t3.a AS t3a, t2.b t2b, t2.c t2c, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 
t3 ON (t2.a = t3."..., params=params@entry=0x0, queryEnv=queryEnv@entry=0x0,
    dest=dest@entry=0x207ca18) at ../../../src/include/nodes/nodes.h:590
#12935 0x00000000007afc6d in standard_ProcessUtility (pstmt=0x206d9e0,
    queryString=0x1fa95b0 "EXPLAIN (COSTS OFF)\nSELECT t1.a, ss.t2a, ss.t2c 
FROM prt1 t1 LEFT JOIN LATERAL\n\t\t\t  (SELECT t2.a AS t2a, t3.a AS t3a, t2.b 
t2b, t2.c t2c, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = 
t3."...,
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0,
    dest=0x207ca18, completionTag=0x7ffea461cfc0 "") at utility.c:670
#12936 0x00000000007ad044 in PortalRunUtility (portal=0x20108f0,
    pstmt=0x206d9e0, isTopLevel=<optimized out>,
    setHoldSnapshot=<optimized out>, dest=0x207ca18,
    completionTag=0x7ffea461cfc0 "") at pquery.c:1175
#12937 0x00000000007adf76 in FillPortalStore (portal=0x20108f0,
    isTopLevel=<optimized out>) at ../../../src/include/nodes/nodes.h:590
#12938 0x00000000007aeb05 in PortalRun (portal=portal@entry=0x20108f0,
    count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true,
    run_once=run_once@entry=true, dest=dest@entry=0x20e9948,
    altdest=altdest@entry=0x20e9948, completionTag=0x7ffea461d1e0 "")
    at pquery.c:765
#12939 0x00000000007aa551 in exec_simple_query (
    query_string=0x1fa95b0 "EXPLAIN (COSTS OFF)\nSELECT t1.a, ss.t2a, ss.t2c 
FROM prt1 t1 LEFT JOIN LATERAL\n\t\t\t  (SELECT t2.a AS t2a, t3.a AS t3a, t2.b 
t2b, t2.c t2c, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = 
t3."...)
    at postgres.c:1227
#12940 0x00000000007abfed in PostgresMain (argc=<optimized out>,
    argv=argv@entry=0x1fd4b38, dbname=<optimized out>,
    username=<optimized out>) at postgres.c:4291
#12941 0x000000000072acef in BackendRun (port=0x1fcb2b0, port=0x1fcb2b0)
    at postmaster.c:4498
#12942 BackendStartup (port=0x1fcb2b0) at postmaster.c:4189
#12943 ServerLoop () at postmaster.c:1727
#12944 0x000000000072bbff in PostmasterMain (argc=argc@entry=8,
    argv=argv@entry=0x1fa5160) at postmaster.c:1400
#12945 0x000000000047d2be in main (argc=8, argv=0x1fa5160) at main.c:210







Attachment: pgsql13-asymmetric-partitionwise-join.v2.patch
Description: Binary data

Reply via email to