Re: sqlsmith crash incremental sort

Justin Pryzby <pryzby@telsasoft.com>

From: Justin Pryzby <pryzby@telsasoft.com>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: James Coleman <jtc331@gmail.com>, pgsql-hackers@postgresql.org
Date: 2020-04-11T21:46:39Z
Lists: pgsql-hackers
Adding -hackers, originally forgotten.

On Sat, Apr 11, 2020 at 10:26:39PM +0200, Tomas Vondra wrote:
> Thanks! I'll investigate.
> 
> On Sat, Apr 11, 2020 at 02:19:52PM -0500, Justin Pryzby wrote:
> > frequent crash looks like:
> > 
> > #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
> > #1  0x00007fb0a0cda801 in __GI_abort () at abort.c:79
> > #2  0x00007fb0a21ec425 in ExceptionalCondition (conditionName=conditionName@entry=0x7fb0a233a2ed "relid > 0", errorType=errorType@entry=0x7fb0a224701d "FailedAssertion",
> >    fileName=fileName@entry=0x7fb0a2340ce8 "relnode.c", lineNumber=lineNumber@entry=379) at assert.c:67
> > #3  0x00007fb0a2010d3a in find_base_rel (root=root@entry=0x7fb0a2de2d00, relid=<optimized out>) at relnode.c:379
> > #4  0x00007fb0a2199666 in examine_variable (root=root@entry=0x7fb0a2de2d00, node=node@entry=0x7fb0a2e65eb8, varRelid=varRelid@entry=0, vardata=vardata@entry=0x7ffe7b549e60) at selfuncs.c:4600
> > #5  0x00007fb0a219e2ed in estimate_num_groups (root=root@entry=0x7fb0a2de2d00, groupExprs=0x7fb0a2e69118, input_rows=input_rows@entry=2, pgset=pgset@entry=0x0) at selfuncs.c:3279
> > #6  0x00007fb0a1fc198b in cost_incremental_sort (path=path@entry=0x7fb0a2e69080, root=root@entry=0x7fb0a2de2d00, pathkeys=pathkeys@entry=0x7fb0a2e68b28, presorted_keys=presorted_keys@entry=3,
> >    input_startup_cost=103.73424154497742, input_total_cost=<optimized out>, input_tuples=2, width=480, comparison_cost=comparison_cost@entry=0, sort_mem=4096, limit_tuples=-1) at costsize.c:1832
> > #7  0x00007fb0a2007f63 in create_incremental_sort_path (root=root@entry=0x7fb0a2de2d00, rel=rel@entry=0x7fb0a2e67a38, subpath=subpath@entry=0x7fb0a2e681a0, pathkeys=0x7fb0a2e68b28,
> >    presorted_keys=3, limit_tuples=limit_tuples@entry=-1) at pathnode.c:2793
> > #8  0x00007fb0a1fe97cb in create_ordered_paths (limit_tuples=-1, target_parallel_safe=true, target=0x7fb0a2e65568, input_rel=<optimized out>, root=0x7fb0a2de2d00) at planner.c:5029
> > #9  grouping_planner (root=root@entry=0x7fb0a2de2d00, inheritance_update=inheritance_update@entry=false, tuple_fraction=<optimized out>, tuple_fraction@entry=0) at planner.c:2254
> > #10 0x00007fb0a1fecd5c in subquery_planner (glob=<optimized out>, parse=parse@entry=0x7fb0a2db7840, parent_root=parent_root@entry=0x7fb0a2dad650, hasRecursion=hasRecursion@entry=false,
> >    tuple_fraction=0) at planner.c:1015
> > #11 0x00007fb0a1fbc286 in set_subquery_pathlist (rte=<optimized out>, rti=<optimized out>, rel=0x7fb0a2db3598, root=0x7fb0a2dad650) at allpaths.c:2303
> > #12 set_rel_size (root=root@entry=0x7fb0a2dad650, rel=rel@entry=0x7fb0a2db1670, rti=rti@entry=2, rte=<optimized out>) at allpaths.c:422
> > #13 0x00007fb0a1fbecad in set_base_rel_sizes (root=<optimized out>) at allpaths.c:323
> > #14 make_one_rel (root=root@entry=0x7fb0a2dad650, joinlist=joinlist@entry=0x7fb0a2db76b8) at allpaths.c:185
> > #15 0x00007fb0a1fe4a2b in query_planner (root=root@entry=0x7fb0a2dad650, qp_callback=qp_callback@entry=0x7fb0a1fe52c0 <standard_qp_callback>, qp_extra=qp_extra@entry=0x7ffe7b54a510)
> >    at planmain.c:269
> > #16 0x00007fb0a1fea0b8 in grouping_planner (root=root@entry=0x7fb0a2dad650, inheritance_update=inheritance_update@entry=false, tuple_fraction=<optimized out>, tuple_fraction@entry=0)
> >    at planner.c:2058
> > #17 0x00007fb0a1fecd5c in subquery_planner (glob=glob@entry=0x7fb0a2dab480, parse=parse@entry=0x7fb0a2d48410, parent_root=parent_root@entry=0x0, hasRecursion=hasRecursion@entry=false,
> >    tuple_fraction=tuple_fraction@entry=0) at planner.c:1015
> > #18 0x00007fb0a1fee1df in standard_planner (parse=0x7fb0a2d48410, query_string=<optimized out>, cursorOptions=256, boundParams=<optimized out>) at planner.c:405
> > 
> > Minimal query like:
> > 
> > explain SELECT * FROM information_schema.transforms AS ref_1 RIGHT JOIN (SELECT 1 FROM pg_catalog.pg_namespace TABLESAMPLE SYSTEM (7.2))AS sample_2 ON (ref_1.specific_name is NULL);
> > 
> > -- 
> > Justin



Commits

  1. Simplify cost_incremental_sort a bit

  2. Fix cost_incremental_sort for expressions with varno 0