BUG #17781: Assert in setrefs.c

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: tharakan(at)gmail(dot)com
Subject: BUG #17781: Assert in setrefs.c
Date: 2023-02-07 13:16:08
Message-ID: 17781-c0405c8b3cd5e072@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17781
Logged by: Robins Tharakan
Email address: tharakan(at)gmail(dot)com
PostgreSQL version: 15.1
Operating system: Ubuntu 20.04
Description:

This assert() is easily reproducible as of aa69541046(at)master, although I can
trace the issue back to last week's commit 2489d76c49.

TRAP: failed Assert("nrm_match == NRM_SUBSET ?
bms_is_subset(phv->phnullingrels, subphv->phnullingrels) : nrm_match ==
NRM_SUPERSET ? bms_is_subset(subphv->phnullingrels, phv->phnullingrels) :
bms_equal(subphv->phnullingrels, phv->phnullingrels)"), File: "setrefs.c",
Line: 2845, PID: 3217440

Backtrace / SQL / backtrace full (excerpt) below.

SQL
===
rollback;
begin;
create table t6();
create table n(a numeric);
create table t(a text);
create table l();
create table n2(n numeric);
create table f();
SELECT subq_3.c1 AS c8
FROM t6 AS sample_0
LEFT JOIN (n AS ref_1
RIGHT JOIN f AS sample_1 ON NULL
LEFT JOIN (n2 AS sample_3
RIGHT JOIN t AS sample_4 ON NULL)
ON ref_1.a = sample_3.n
LEFT JOIN ((SELECT NULL AS c1
FROM l AS ref_2) AS subq_3
INNER JOIN pg_catalog.pg_stat_gssapi AS ref_4 ON
NULL)
ON ref_4.principal !~~ sample_4.a)
ON NULL;

Checking (aa69541046~49) - b448f1c8d8 - Crash
Checking (aa69541046~50) - 2489d76c49 - Crash
Checking (aa69541046~51) - ec7e053a98 - Success
Checking (aa69541046~52) - fe9e658f4d - Success

Backtrace
=========
Core was generated by `postgres: aa69541046(at)master@sqith: ubuntu postgres
127.0.'.
Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#0 __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007f5d5b59f859 in __GI_abort () at abort.c:79
#2 0x000055dbe02e80d7 in ExceptionalCondition (
conditionName=0x55dbe049fec0 "nrm_match == NRM_SUBSET ?
bms_is_subset(phv->phnullingrels, subphv->phnullingrels) : nrm_match ==
NRM_SUPERSET ? bms_is_subset(subphv->phnullingrels, phv->phnullingrels) :
bms_equal(subphv->phnullingr"..., fileName=0x55dbe049f8ef "setrefs.c",
lineNumber=2845) at assert.c:66
#3 0x000055dbdffd7e28 in search_indexed_tlist_for_phv
(phv=0x55dbe14dc5c8,
itlist=0x55dbe14e8a60, newvarno=-1, nrm_match=NRM_SUPERSET)
at setrefs.c:2845
#4 0x000055dbdffd82df in fix_join_expr_mutator (node=0x55dbe14dc5c8,
context=0x7ffdf5c7c660) at setrefs.c:3066
#5 0x000055dbdff14963 in expression_tree_mutator_impl
(node=0x55dbe14e8840,
mutator=0x55dbdffd80b7 <fix_join_expr_mutator>,
context=0x7ffdf5c7c660)
at nodeFuncs.c:3051
#6 0x000055dbdffd843b in fix_join_expr_mutator (node=0x55dbe14e8840,
context=0x7ffdf5c7c660) at setrefs.c:3104
#7 0x000055dbdff14d6e in expression_tree_mutator_impl
(node=0x55dbe14e8890,
mutator=0x55dbdffd80b7 <fix_join_expr_mutator>,
context=0x7ffdf5c7c660)
at nodeFuncs.c:3137
#8 0x000055dbdffd843b in fix_join_expr_mutator (node=0x55dbe14e8890,
context=0x7ffdf5c7c660) at setrefs.c:3104
#9 0x000055dbdffd80a1 in fix_join_expr (root=0x55dbe14d4f80,
clauses=0x55dbe14e8890, outer_itlist=0x55dbe14e8a10,
inner_itlist=0x55dbe14e8a60, acceptable_rel=0, rtoffset=0,
nrm_match=NRM_SUPERSET, num_exec=2910) at setrefs.c:2999
#10 0x000055dbdffd7111 in set_join_references (root=0x55dbe14d4f80,
join=0x55dbe14e87b0, rtoffset=0) at setrefs.c:2350
#11 0x000055dbdffd3ef9 in set_plan_refs (root=0x55dbe14d4f80,
plan=0x55dbe14e87b0, rtoffset=0) at setrefs.c:870
#12 0x000055dbdffd2a1f in set_plan_references (root=0x55dbe14d4f80,
plan=0x55dbe14e87b0) at setrefs.c:354
#13 0x000055dbdffc43cd in standard_planner (parse=0x55dbe14bd2c8,
query_string=0x55dbe13951a8 "SELECT subq_3.c1 AS c8\nFROM t6 AS
sample_0\n LEFT JOIN (n AS ref_1\n", ' ' <repeats 16 times>, "RIGHT JOIN
f AS sample_1 ON NULL\n", ' ' <repeats 16 times>, "LEFT JOIN (n2 AS
sample_3\n", ' ' <repeats 27 times>, "RIGHT JOIN t"..., cursorOptions=2048,
boundParams=0x0)
at planner.c:504

Backtrace full excerpt
======================
#2 0x000055dbe02e80d7 in ExceptionalCondition (
conditionName=0x55dbe049fec0 "nrm_match == NRM_SUBSET ?
bms_is_subset(phv->phnullingrels, subphv->phnullingrels) : nrm_match ==
NRM_SUPERSET ? bms_is_subset(subphv->phnullingrels, phv->phnullingrels) :
bms_equal(subphv->phnullingr"..., fileName=0x55dbe049f8ef "setrefs.c",
lineNumber=2845) at assert.c:66
No locals.
#3 0x000055dbdffd7e28 in search_indexed_tlist_for_phv
(phv=0x55dbe14dc5c8,
itlist=0x55dbe14e8a60, newvarno=-1, nrm_match=NRM_SUPERSET)
at setrefs.c:2845
subphv = 0x55dbe14e7120
newvar = 0x0
tle = 0x55dbe14e85f0
lc__state = {l = 0x55dbe14e8640, i = 0}
lc = 0x55dbe14e8658
#4 0x000055dbdffd82df in fix_join_expr_mutator (node=0x55dbe14dc5c8,
context=0x7ffdf5c7c660) at setrefs.c:3066
phv = 0x55dbe14dc5c8
newvar = 0x0
__func__ = "fix_join_expr_mutator"
#5 0x000055dbdff14963 in expression_tree_mutator_impl
(node=0x55dbe14e8840,
mutator=0x55dbdffd80b7 <fix_join_expr_mutator>,
context=0x7ffdf5c7c660)
at nodeFuncs.c:3051
targetentry = 0x55dbe14e8840
newnode = 0x55dbe14e9820
__func__ = "expression_tree_mutator_impl"
#6 0x000055dbdffd843b in fix_join_expr_mutator (node=0x55dbe14e8840,
context=0x7ffdf5c7c660) at setrefs.c:3104
newvar = 0x15c31daf4ca7e00
__func__ = "fix_join_expr_mutator"
#7 0x000055dbdff14d6e in expression_tree_mutator_impl
(node=0x55dbe14e8890,
mutator=0x55dbdffd80b7 <fix_join_expr_mutator>,
context=0x7ffdf5c7c660)
at nodeFuncs.c:3137
temp__state = {l = 0x55dbe14e8890, i = 0}
resultlist = 0x0
temp = 0x55dbe14e88a8
__func__ = "expression_tree_mutator_impl"
#8 0x000055dbdffd843b in fix_join_expr_mutator (node=0x55dbe14e8890,
context=0x7ffdf5c7c660) at setrefs.c:3104
newvar = 0x55dbe14e8a60
__func__ = "fix_join_expr_mutator"
#9 0x000055dbdffd80a1 in fix_join_expr (root=0x55dbe14d4f80,
clauses=0x55dbe14e8890, outer_itlist=0x55dbe14e8a10,
inner_itlist=0x55dbe14e8a60, acceptable_rel=0, rtoffset=0,
nrm_match=NRM_SUPERSET, num_exec=2910) at setrefs.c:2999
context = {root = 0x55dbe14d4f80, outer_itlist = 0x55dbe14e8a10,
inner_itlist = 0x55dbe14e8a60, acceptable_rel = 0, rtoffset = 0,
nrm_match = NRM_SUPERSET, num_exec = 2910}
#10 0x000055dbdffd7111 in set_join_references (root=0x55dbe14d4f80,
join=0x55dbe14e87b0, rtoffset=0) at setrefs.c:2350
outer_plan = 0x55dbe14e8560
inner_plan = 0x55dbe14e86f0
outer_itlist = 0x55dbe14e8a10
inner_itlist = 0x55dbe14e8a60
__func__ = "set_join_references"
#11 0x000055dbdffd3ef9 in set_plan_refs (root=0x55dbe14d4f80,
plan=0x55dbe14e87b0, rtoffset=0) at setrefs.c:870
l = 0x55dbe1395090
__func__ = "set_plan_refs"
#12 0x000055dbdffd2a1f in set_plan_references (root=0x55dbe14d4f80,
plan=0x55dbe14e87b0) at setrefs.c:354
result = 0x55dbe14dc108
glob = 0x55dbe14d6678
rtoffset = 0
lc = 0x0
#13 0x000055dbdffc43cd in standard_planner (parse=0x55dbe14bd2c8,
query_string=0x55dbe13951a8 "SELECT subq_3.c1 AS c8\nFROM t6 AS
sample_0\n LEFT JOIN (n AS ref_1\n", ' ' <repeats 16 times>, "RIGHT JOIN
f AS sample_1 ON NULL\n", ' ' <repeats 16 times>, "LEFT JOIN (n2 AS
sample_3\n", ' ' <repeats 27 times>, "RIGHT JOIN t"..., cursorOptions=2048,
boundParams=0x0)
at planner.c:504
result = 0x0
glob = 0x55dbe14d6678
tuple_fraction = 0
root = 0x55dbe14d4f80
final_rel = 0x55dbe14e81f0
best_path = 0x55dbe14e8050
top_plan = 0x55dbe14e87b0
lp = 0x4d430000
lr = 0x55dbe14d55a0

Thanks to SQLSmith / SQLReduce for the find.

-
Robins Tharakan
Amazon Web Services

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-02-07 13:16:22 BUG #17782: ERROR: variable not found in subplan target lists
Previous Message Masahiko Sawada 2023-02-07 08:20:26 Re: WAL segments removed from primary despite the fact that logical replication slot needs it.