Hi,

The attached query makes beta2 crash with attached backtrace.
Interestingly the index on ref_6 is needed to make it crash, without
it the query works fine.

-- 
Jaime Casanova
Director de Servicios Profesionales
SYSTEMGUARDS - Consultores de PostgreSQL
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
        set = {__val = {4194304, 140734892134240, 2, 6, 7058365, 
94467046612912, 4611686018427388799, 140602878769846, 0, 281470681751456, 0, 0, 
0, 0, 0, 0}}
        pid = <optimized out>
        tid = <optimized out>
        ret = <optimized out>
#1  0x00007fe0a7c60535 in __GI_abort () at abort.c:79
        save_stage = 1
        act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, 
sa_mask = {__val = {0, 0, 0, 0, 0, 140602865618952, 2, 7018074096076324867, 
              7017846515177828964, 94467046612912, 7003721282549509696, 0, 
6603711216602630912, 140734892134480, 0, 140734892135344}}, 
          sa_flags = -759062608, sa_restorer = 0x0}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x000055ead332796a in ExceptionalCondition (conditionName=0x55ead34de1f0 
"!bms_overlap(joinrel->relids, required_outer)", 
    fileName=0x55ead34ddcef "relnode.c", lineNumber=1652) at assert.c:66
No locals.
#3  0x000055ead306f7b8 in get_joinrel_parampathinfo (root=0x7fe09c5bd0a0, 
joinrel=0x7fe09c399d98, outer_path=0x7fe09c391e68, inner_path=0x7fe09c38fd28, 
    sjinfo=0x7fe09c4766a0, required_outer=0x7fe09c39a218, 
restrict_clauses=0x7fff6540d548) at relnode.c:1652
        ppi = 0x10
        join_and_req = 0x7fff6540d4a0
        outer_and_req = 0x0
        inner_and_req = 0x7fe09c391a78
        pclauses = 0x55ead4a896e0
        eclauses = 0x386540d4a0
        dropped_ecs = 0x68
        rows = 4.6672926152656088e-310
        lc = 0x55ead3366497 <MemoryContextAllocZeroAligned+252>
#4  0x000055ead30605b6 in create_nestloop_path (root=0x7fe09c5bd0a0, 
joinrel=0x7fe09c399d98, jointype=JOIN_LEFT, workspace=0x7fff6540d590, 
    extra=0x7fff6540d740, outer_path=0x7fe09c391e68, inner_path=0x7fe09c38fd28, 
restrict_clauses=0x0, pathkeys=0x0, required_outer=0x7fe09c39a218)
    at pathnode.c:2462
        pathnode = 0x7fe09c399a08
        inner_req_outer = 0x0
#5  0x000055ead3007a7d in try_nestloop_path (root=0x7fe09c5bd0a0, 
joinrel=0x7fe09c399d98, outer_path=0x7fe09c391e68, inner_path=0x7fe09c38fd28, 
    pathkeys=0x0, jointype=JOIN_LEFT, extra=0x7fff6540d740) at joinpath.c:775
        required_outer = 0x7fe09c39a218
        workspace = {startup_cost = 2.1989999999999998, total_cost = 
10.754533615595889, run_cost = 8.5555336155958894, 
          inner_run_cost = 6.9466950277108173e-310, inner_rescan_run_cost = 0, 
outer_rows = 0, inner_rows = 6.9532275375539389e-310, 
          outer_skip_rows = 4.667292444873237e-310, inner_skip_rows = 
3.9525251667299724e-322, numbuckets = 0, numbatches = 0, 
          inner_rows_total = 6.946694916976477e-310}
        innerrel = 0x7fe09c4743d0
        outerrel = 0x7fe09c391868
        innerrelids = 0x7fe09c474670
        outerrelids = 0x7fe09c391a78
        inner_paramrels = 0x0
        outer_paramrels = 0x7fe09c391d18
#6  0x000055ead300904d in match_unsorted_outer (root=0x7fe09c5bd0a0, 
joinrel=0x7fe09c399d98, outerrel=0x7fe09c391868, innerrel=0x7fe09c4743d0, 
    jointype=JOIN_LEFT, extra=0x7fff6540d740) at joinpath.c:1802
        innerpath = 0x7fe09c38fd28
        mpath = 0x0
        lc2__state = {l = 0x7fe09c38ff68, i = 0}
        lc2 = 0x7fe09c38ff80
        outerpath = 0x7fe09c391e68
        merge_pathkeys = 0x0
        lc1__state = {l = 0x7fe09c391dd8, i = 0}
        save_jointype = JOIN_LEFT
        nestjoinOK = true
        useallclauses = false
        inner_cheapest_total = 0x7fe09c38fd28
        matpath = 0x7fe09c393458
        lc1 = 0x7fe09c391df0
        __func__ = "match_unsorted_outer"
#7  0x000055ead3006ed3 in add_paths_to_joinrel (root=0x7fe09c5bd0a0, 
joinrel=0x7fe09c399d98, outerrel=0x7fe09c391868, innerrel=0x7fe09c4743d0, 
    jointype=JOIN_LEFT, sjinfo=0x7fe09c4766a0, restrictlist=0x0) at 
joinpath.c:294
        extra = {restrictlist = 0x0, mergeclause_list = 0x0, inner_unique = 
false, sjinfo = 0x7fe09c4766a0, semifactors = {
            outer_match_frac = 6.946694916976477e-310, match_count = 0}, 
param_source_rels = 0x7fe09c39a1f8}
        mergejoin_allowed = true
        lc = 0x0
        joinrelids = 0x7fe09c399d78
#8  0x000055ead300b9e9 in populate_joinrel_with_paths (root=0x7fe09c5bd0a0, 
rel1=0x7fe09c391868, rel2=0x7fe09c4743d0, joinrel=0x7fe09c399d98, 
    sjinfo=0x7fe09c4766a0, restrictlist=0x0) at joinrels.c:942
        __func__ = "populate_joinrel_with_paths"
#9  0x000055ead300b5b7 in make_join_rel (root=0x7fe09c5bd0a0, 
rel1=0x7fe09c391868, rel2=0x7fe09c4743d0) at joinrels.c:776
        joinrelids = 0x7fe09c38fe58
        sjinfo = 0x7fe09c4766a0
        reversed = false
        pushed_down_joins = 0x0
        sjinfo_data = {type = 2621925520, min_lefthand = 0x7fe09c474670, 
min_righthand = 0x7fe09c4737a0, syn_lefthand = 0x1, syn_righthand = 
0x7fff6540d8c0, 
          jointype = 3540362286, ojrelid = 21994, commute_above_l = 0x0, 
commute_above_r = 0x7fe09c4743d0, commute_below_l = 0x7fe09c391868, 
          commute_below_r = 0x7fe09c5bd0a0, lhs_strict = 184, semi_can_btree = 
27, semi_can_hash = 57, semi_operators = 0x0, semi_rhs_exprs = 0x0}
        joinrel = 0x7fe09c399d98
        restrictlist = 0x0
#10 0x000055ead300aa49 in make_rels_by_clause_joins (root=0x7fe09c5bd0a0, 
old_rel=0x7fe09c391868, other_rels_list=0x7fe09c38ffb8, 
other_rels=0x7fe09c390008)
    at joinrels.c:312
        other_rel = 0x7fe09c4743d0
        l__state = {l = 0x7fe09c38ffb8, i = 5}
        l = 0x7fe09c390030
#11 0x000055ead300a51b in join_search_one_level (root=0x7fe09c5bd0a0, level=3) 
at joinrels.c:123
        other_rels_list = 0x7fe09c38ffb8
        other_rels = 0x7fe09c390008
        old_rel = 0x7fe09c391868
        r__state = {l = 0x7fe09c390268, i = 4}
        joinrels = 0x7fe09c390098
        r = 0x7fe09c393508
        k = 32736
        __func__ = "join_search_one_level"
#12 0x000055ead2fed280 in standard_join_search (root=0x7fe09c5bd0a0, 
levels_needed=7, initial_rels=0x7fe09c38ffb8) at allpaths.c:3454
        lc = 0x0
        lev = 3
        rel = 0x7fe09c394338
        __func__ = "standard_join_search"
#13 0x000055ead2fed1ee in make_rel_from_joinlist (root=0x7fe09c5bd0a0, 
joinlist=0x7fe09c475790) at allpaths.c:3385
        levels_needed = 7
        initial_rels = 0x7fe09c38ffb8
        jl = 0x0
        __func__ = "make_rel_from_joinlist"
#14 0x000055ead2fe8353 in make_one_rel (root=0x7fe09c5bd0a0, 
joinlist=0x7fe09c475790) at allpaths.c:229
        rel = 0x7fe09c51dc50
        rti = 13
        total_pages = 30
#15 0x000055ead30279e9 in query_planner (root=0x7fe09c5bd0a0, 
qp_callback=0x55ead302e070 <standard_qp_callback>, qp_extra=0x7fff6540dba0) at 
planmain.c:278
        parse = 0x7fe09c51dc50
        joinlist = 0x7fe09c475790
        final_rel = 0x7fe09c51de00
        __func__ = "query_planner"
#16 0x000055ead302a345 in grouping_planner (root=0x7fe09c5bd0a0, 
tuple_fraction=0) at planner.c:1493
        sort_input_targets = 0x7fe09c51e648
        sort_input_target_parallel_safe = false
        grouping_target = 0x7fff6540dd60
        scanjoin_target = 0x7fff6540dd60
        activeWindows = 0x0
        qp_extra = {activeWindows = 0x0, gset_data = 0x0}
        sort_input_targets_contain_srfs = 0x9c51e9b8
        have_grouping = false
        wflists = 0x0
        gset_data = 0x0
        sort_input_target = 0x0
        grouping_targets = 0x7fe09c51e9b8
        grouping_target_parallel_safe = false
        scanjoin_targets = 0x55ead2f7d494 <list_concat+230>
        scanjoin_target_parallel_safe = false
        grouping_targets_contain_srfs = 0x7fe09c51ea58
        scanjoin_targets_contain_srfs = 0x7fff6540dbe0
        scanjoin_target_same_exprs = false
        parse = 0x7fe09c51dc50
        offset_est = 0
        count_est = 0
        limit_tuples = -1
        have_postponed_srfs = false
        final_target = 0x7fe09c5bd0a0
        final_targets = 0x7fe09c51e648
        final_targets_contain_srfs = 0x7fe09c5bd0a0
        final_target_parallel_safe = false
        current_rel = 0x7fe09c51d3b0
        final_rel = 0x7fe09c5bd0a0
        extra = {limit_needed = 112, limit_tuples = 4.6672924561231612e-310, 
count_est = 140734892137784, offset_est = 140602672013056}
        lc = 0x7fe000000000
        __func__ = "grouping_planner"
#17 0x000055ead3029a3c in subquery_planner (glob=0x7fe09c5ba740, 
parse=0x55ead4b7dea8, parent_root=0x0, hasRecursion=false, tuple_fraction=0)
    at planner.c:1062
        root = 0x7fe09c5bd0a0
        newWithCheckOptions = 0x0
        newHaving = 0x0
        hasOuterJoins = true
        hasResultRTEs = false
        final_rel = 0x0
        l = 0x0
#18 0x000055ead3028040 in standard_planner (parse=0x55ead4b7dea8, 
    query_string=0x55ead4a897f8 "select subq_0.p30_moneda as c1, subq_6.c0 as 
c2 \n  from public.subq_0, \n       lateral (select subq_0.p30_moneda as c0 
from (select 1) foo offset 0) as subq_6,\n       lateral (select 
sample_3.parname "..., cursorOptions=2048, boundParams=0x0) at planner.c:411
        result = 0x0
        glob = 0x7fe09c5ba740
        tuple_fraction = 0
        root = 0x55ead4ad68f8
        final_rel = 0x7fe09c525c18
        best_path = 0x55ead336cceb <ResourceOwnerForgetCatCacheRef+50>
        top_plan = 0x7fff6540dfc0
        lp = 0x8a590
        lr = 0x55ead4ad6958
#19 0x00007fe0a57d1989 in pgss_planner (parse=0x55ead4b7dea8, 
    query_string=0x55ead4a897f8 "select subq_0.p30_moneda as c1, subq_6.c0 as 
c2 \n  from public.subq_0, \n       lateral (select subq_0.p30_moneda as c0 
from (select 1) foo offset 0) as subq_6,\n       lateral (select 
sample_3.parname "..., cursorOptions=2048, boundParams=0x0) at 
pg_stat_statements.c:956
        result = 0x55ead4b7dea8
#20 0x000055ead3027dcc in planner (parse=0x55ead4b7dea8, 
    query_string=0x55ead4a897f8 "select subq_0.p30_moneda as c1, subq_6.c0 as 
c2 \n  from public.subq_0, \n       lateral (select subq_0.p30_moneda as c0 
from (select 1) foo offset 0) as subq_6,\n       lateral (select 
sample_3.parname "..., cursorOptions=2048, boundParams=0x0) at planner.c:279
        result = 0x55ead4b7dea8
#21 0x000055ead3160b65 in pg_plan_query (querytree=0x55ead4b7dea8, 
    query_string=0x55ead4a897f8 "select subq_0.p30_moneda as c1, subq_6.c0 as 
c2 \n  from public.subq_0, \n       lateral (select subq_0.p30_moneda as c0 
from (select 1) foo offset 0) as subq_6,\n       lateral (select 
sample_3.parname "..., cursorOptions=2048, boundParams=0x0) at postgres.c:904
        plan = 0x3ad3160a9d
#22 0x000055ead3160cb5 in pg_plan_queries (querytrees=0x55ead4bcba58, 
    query_string=0x55ead4a897f8 "select subq_0.p30_moneda as c1, subq_6.c0 as 
c2 \n  from public.subq_0, \n       lateral (select subq_0.p30_moneda as c0 
from (select 1) foo offset 0) as subq_6,\n       lateral (select 
sample_3.parname "..., cursorOptions=2048, boundParams=0x0) at postgres.c:996
        query = 0x55ead4b7dea8
        stmt = 0x55ead4b7dd18
        query_list__state = {l = 0x55ead4bcba58, i = 0}
        stmt_list = 0x0
        query_list = 0x55ead4bcba70
#23 0x000055ead3161043 in exec_simple_query (
    query_string=0x55ead4a897f8 "select subq_0.p30_moneda as c1, subq_6.c0 as 
c2 \n  from public.subq_0, \n       lateral (select subq_0.p30_moneda as c0 
from (select 1) foo offset 0) as subq_6,\n       lateral (select 
sample_3.parname "...) at postgres.c:1193
        cmdtaglen = 6
        snapshot_set = true
        per_parsetree_context = 0x0
        plantree_list = 0x0
        parsetree = 0x55ead4b7dd18
        commandTag = CMDTAG_SELECT
        qc = {commandTag = 1698751344, nprocessed = 94467054122355}
        querytree_list = 0x55ead4bcba58
        portal = 0x55ead4a897f8
        receiver = 0x7fff6540e3a0
        format = 0
        cmdtagname = 0x55ead35085b6 "SELECT"
        parsetree_item__state = {l = 0x55ead4b7dd48, i = 0}
        dest = DestRemote
        oldcontext = 0x55ead4ab54f0
        parsetree_list = 0x55ead4b7dd48
        parsetree_item = 0x55ead4b7dd60
        save_log_statement_stats = false
        was_logged = false
        use_implicit_block = false
        msec_str = 
"\370\227\250\324\352U\000\000b\003\000\000\006\000\000\000\200\343@e\377\177\000\000X\004\365\322b\003\000"
        __func__ = "exec_simple_query"
#24 0x000055ead3165b0e in PostgresMain (dbname=0x55ead4ad41b8 "postgres", 
username=0x55ead4ad4198 "jcasanov") at postgres.c:4632
        query_string = 0x55ead4a897f8 "select subq_0.p30_moneda as c1, 
subq_6.c0 as c2 \n  from public.subq_0, \n       lateral (select 
subq_0.p30_moneda as c0 from (select 1) foo offset 0) as subq_6,\n       
lateral (select sample_3.parname "...
        firstchar = 81
        input_message = {
          data = 0x55ead4a897f8 "select subq_0.p30_moneda as c1, subq_6.c0 as 
c2 \n  from public.subq_0, \n       lateral (select subq_0.p30_moneda as c0 
from (select 1) foo offset 0) as subq_6,\n       lateral (select 
sample_3.parname "..., len = 867, maxlen = 1024, cursor = 867}
        local_sigjmp_buf = {{__jmpbuf = {0, 8400458845551397693, 
94467046612912, 140734892142144, 0, 0, 8400458845496871741, 
2359605153249561405}, 
            __mask_was_saved = 1, __saved_mask = {__val = {4194304, 
18446744073709551536, 0, 0, 140602864575907, 15616, 94467078889880, 
14583653712, 
                94467078905496, 140734892139856, 94467054216220, 15616, 
94467078496496, 0, 0, 94467078820344}}}}
        send_ready_for_query = false
        idle_in_transaction_timeout_enabled = false
        idle_session_timeout_enabled = false
        __func__ = "PostgresMain"
#25 0x000055ead3097b9a in BackendRun (port=0x55ead4abded0) at postmaster.c:4461
No locals.
#26 0x000055ead30974e8 in BackendStartup (port=0x55ead4abded0) at 
postmaster.c:4189
        bn = 0x55ead4ab9430
        pid = 0
        __func__ = "BackendStartup"
#27 0x000055ead3093b6e in ServerLoop () at postmaster.c:1779
        port = 0x55ead4abded0
        i = 0
        now = 1687837990
        last_lockfile_recheck_time = 1687837990
        last_touch_time = 1687835531
        events = {{pos = 3, events = 2, fd = 9, user_data = 0x0}, {pos = 513, 
events = 0, fd = 1698752048, user_data = 0x400}, {pos = 155, events = 120, 
            fd = 8, user_data = 0x760000007c}, {pos = 1, events = 0, fd = 
1698752160, user_data = 0x802f}, {pos = 32816, events = 0, fd = 2050, 
            user_data = 0xffffffffffffffb0}, {pos = 0, events = 0, fd = 0, 
user_data = 0x7fe0a7cc25a3 <__GI___libc_malloc+147>}, {pos = 1060, events = 0, 
            fd = 1698752240, user_data = 0x8000}, {pos = 10, events = 0, fd = 
1, user_data = 0x7fe0a7cff916 <__alloc_dir+86>}, {pos = 1698753555, 
            events = 32767, fd = 10, user_data = 0x7fff6540e6f0}, {pos = 
-759062608, events = 21994, fd = 1698754112, 
            user_data = 0x7fe0a7cffa1d <opendir_tail+93>}, {pos = 2065, events 
= 0, fd = 24645665, user_data = 0x2}, {pos = 16832, events = 1000, fd = 1000, 
            user_data = 0x0}, {pos = 4096, events = 0, fd = 4096, user_data = 
0x8}, {pos = 282905344, events = 1537546333, fd = 116822542, user_data = 0xa}, 
          {pos = 1698752432, events = 32767, fd = -759062608, user_data = 
0x7fff6540ee40}, {pos = 0, events = 0, fd = 0, 
            user_data = 0x7fe0a7cffafd <__closedir+13>}, {pos = 0, events = 0, 
fd = -753783433, user_data = 0x7fff6540e7e0}, {pos = -727140624, 
            events = 21994, fd = 1698754112, user_data = 0xd3123199}, {pos = 
4096, events = 0, fd = 1, user_data = 0x7}, {pos = 0, events = 0, fd = 99, 
            user_data = 0x55ead4a55808}, {pos = 4095, events = 0, fd = 4144, 
user_data = 0xffffffffffffffb0}, {pos = 64, events = 0, fd = 257, 
            user_data = 0x8}, {pos = 99, events = 119, fd = 1, user_data = 
0x6f0000007c}, {pos = 0, events = 0, fd = 0, user_data = 0xfff}, {pos = 4096, 
            events = 0, fd = 255, user_data = 0xffffffffffffffb0}, {pos = 1023, 
events = 0, fd = -727162608, 
            user_data = 0x7fe0a7cc25a3 <__GI___libc_malloc+147>}, {pos = 
-726953736, events = 21994, fd = 4096, user_data = 0x55ead4a86110}, {pos = 10, 
            events = 0, fd = 4096, user_data = 0x7fe0a7cad86a 
<__GI__IO_file_doallocate+170>}, {pos = 2065, events = 0, fd = 24645684, 
user_data = 0x1}, {
            pos = 33152, events = 1000, fd = 1000, user_data = 0x0}, {pos = 
2640, events = 0, fd = 4096, user_data = 0x7fff6540e940}, {pos = -755732434, 
            events = 21994, fd = 228453372, user_data = 0x7fff6540e98f}, {pos = 
1698752910, events = 32767, fd = -726955848, user_data = 0x7fff6540e9a0}, {
            pos = -751454267, events = 21994, fd = 0, user_data = 
0x55ead4ab8510}, {pos = -1, events = 4294967295, fd = 0, user_data = 
0x55ead4ab88b8}, {
            pos = 752, events = 0, fd = -749980866, user_data = 
0x55ead4ab8510}, {pos = 64, events = 0, fd = 282905344, user_data = 0x3}, {pos 
= 0, 
            events = 0, fd = 1698753040, user_data = 0x55ead33597a3 
<wipe_mem+37>}, {pos = 752, events = 0, fd = -726956520, user_data = 
0x7fff6540ea10}, {
            pos = -751460352, events = 21994, fd = -727162608, user_data = 
0x55ead4ab8510}, {pos = -1, events = 4294967295, fd = -726956520, 
            user_data = 0x0}, {pos = -726956608, events = 21994, fd = 88, 
user_data = 0xd4ab8510}, {pos = 1024, events = 0, fd = -726956784, 
            user_data = 0x55ead4ab85c0}, {pos = 0, events = 0, fd = 1698753072, 
user_data = 0x55ead336506b <MemoryContextResetOnly+130>}, {pos = 0, 
            events = 0, fd = -726956784, user_data = 0x7fff6540ea80}, {pos = 
-751459970, events = 21994, fd = 0, user_data = 0x55ead4ab8510}, {
            pos = -759062608, events = 21994, fd = -751228349, user_data = 
0x55ead36e3f90 <context_freelists+16>}, {pos = 1024, events = 0, fd = 
-726956784, 
            user_data = 0x55ead4ab8920}, {pos = 1698753184, events = 32767, fd 
= -751414793, user_data = 0x400}, {pos = 282905344, events = 1537546333, 
            fd = 1698753472, user_data = 0x55ead4a86110}, {pos = 0, events = 0, 
fd = -726994960, user_data = 0x7fff6540ee40}, {pos = 0, events = 0, fd = 0, 
            user_data = 0x7fe0a7cbc3c9 <_IO_flush_all_lockp+665>}, {pos = 
-749980883, events = 1, fd = -726994960, 
            user_data = 0x7fe0a7cbab40 <flush_cleanup>}, {pos = 0, events = 0, 
fd = 0, user_data = 0x0}, {pos = 0, events = 0, fd = 10473, 
            user_data = 0x7fff6540ee40}, {pos = -1479522484, events = 32736, fd 
= 1698753536, user_data = 0x0}, {pos = 1698753536, events = 32767, 
            fd = -759062608, user_data = 0x7fff6540ee40}, {pos = -754381994, 
events = 21994, fd = 4194304, user_data = 0x400}, {pos = -726994960, 
            events = 21994, fd = -726994736, user_data = 0x7fff6540eba0}, {pos 
= -751414793, events = 21994, fd = -727140624, user_data = 0x55ead4aaeff0}, {
            pos = 1698753472, events = 32767, fd = -727148832, user_data = 
0x0}, {pos = -726956784, events = 21994, fd = 1698753584, 
            user_data = 0x55ead2f4ec18 <load_ident+425>}, {pos = 0, events = 0, 
fd = 0, user_data = 0x7fff6540ec30}, {pos = -754348669, events = 21994, 
            fd = 0, user_data = 0x0}}
        nevents = 1
        __func__ = "ServerLoop"
#28 0x000055ead30934e4 in PostmasterMain (argc=3, argv=0x55ead4a82090) at 
postmaster.c:1463
        opt = -1
        status = 0
        userDoption = 0x55ead4a686d0 "data.0"
        listen_addr_saved = true
        i = 64
        output_config_variable = 0x0
        __func__ = "PostmasterMain"
#29 0x000055ead2f567f7 in main (argc=3, argv=0x55ead4a82090) at main.c:198
        do_check_root = true

Attachment: query_to_crash.sql
Description: application/sql

Reply via email to