timescaledb icon indicating copy to clipboard operation
timescaledb copied to clipboard

Coredump in LATERAL query

Open svenklemm opened this issue 1 month ago • 0 comments

Our nightly sqlsmith run produced a coredump.

Query to reproduce:

SELECT FROM metrics m1,
LATERAL(
  SELECT FROM metrics_compressed m2
  WHERE
    m1.time = m2.time AND
    EXISTS (SELECT random()) OR
    EXISTS (SELECT FROM sensors) LIMIT 1
) l;

The query is running against the regresscheck-shared database.

Stacktrace:

#0  0x00007d0977dbf32c in ?? () from /usr/lib/libc.so.6
#1  0x00007d0977d6e6c8 in raise () from /usr/lib/libc.so.6
#2  0x00007d0977d564b8 in abort () from /usr/lib/libc.so.6
#3  0x000060fb7ab1b473 in ExceptionalCondition (conditionName=0x60fb7accb378 "ptr == NULL || nodeTag(ptr) == type", errorType=0x60fb7accb366 "FailedAssertion",
    fileName=0x60fb7accb340 "../../../../src/include/nodes/nodes.h", lineNumber=609) at assert.c:69
#4  0x000060fb7a7e10aa in castNodeImpl (type=T_RestrictInfo, ptr=0x60fb7ccc4a68) at ../../../../src/include/nodes/nodes.h:609
#5  0x000060fb7a7e4cff in match_clauses_to_index (root=0x60fb7cc978a8, clauses=0x60fb7ccc4968, index=0x60fb7ccbbbf0, clauseset=0x7ffde59732a0) at indxpath.c:2135
#6  0x000060fb7a7e32cd in build_paths_for_OR (root=0x60fb7cc978a8, rel=0x60fb7ccb1568, clauses=0x60fb7ccc4968, other_clauses=0x60fb7ccc4e70) at indxpath.c:1215
#7  0x000060fb7a7e3505 in generate_bitmap_or_paths (root=0x60fb7cc978a8, rel=0x60fb7ccb1568, clauses=0x60fb7ccc4b90, other_clauses=0x0) at indxpath.c:1294
#8  0x000060fb7a7e18f5 in create_index_paths (root=0x60fb7cc978a8, rel=0x60fb7ccb1568) at indxpath.c:317
#9  0x00007d092ec9ee89 in create_compressed_scan_paths (root=0x60fb7cc978a8, compressed_rel=0x60fb7ccb1568, info=0x60fb7ccbb9e8, sort_info=0x7ffde5973a40)
    at /home/sven/projects/ts-pg16/tsl/src/nodes/decompress_chunk/decompress_chunk.c:1859
#10 0x00007d092ec9c79a in ts_decompress_chunk_generate_paths (root=0x60fb7cc978a8, chunk_rel=0x60fb7cca4100, ht=0x60fb7cc5ae80, chunk=0x60fb7ccaac68)
    at /home/sven/projects/ts-pg16/tsl/src/nodes/decompress_chunk/decompress_chunk.c:772
#11 0x00007d092ec316d8 in tsl_set_rel_pathlist_query (root=0x60fb7cc978a8, rel=0x60fb7cca4100, rti=2, rte=0x60fb7ccb63a0, ht=0x60fb7cc5ae80)
    at /home/sven/projects/ts-pg16/tsl/src/planner.c:113
#12 0x00007d092ed9755e in apply_optimizations (root=0x60fb7cc978a8, reltype=TS_REL_CHUNK_CHILD, rel=0x60fb7cca4100, rte=0x60fb7ccb63a0, ht=0x60fb7cc5ae80)
    at /home/sven/projects/ts-pg16/src/planner/planner.c:1074
#13 0x00007d092ed97c9a in timescaledb_set_rel_pathlist (root=0x60fb7cc978a8, rel=0x60fb7cca4100, rti=2, rte=0x60fb7ccb63a0) at /home/sven/projects/ts-pg16/src/planner/planner.c:1229
#14 0x00007d092ed7fc55 in set_rel_pathlist (root=0x60fb7cc978a8, rel=0x60fb7cca4100, rti=2, rte=0x60fb7ccb63a0) at /home/sven/projects/ts-pg16/src/import/allpaths.c:285
#15 0x00007d092ed7fa50 in ts_set_append_rel_pathlist (root=0x60fb7cc978a8, parent_rel=0x60fb7cca3c88, parent_rt_index=1, parent_rte=0x60fb7cc7b950)
    at /home/sven/projects/ts-pg16/src/import/allpaths.c:209
#16 0x00007d092ed974b7 in reenable_inheritance (root=0x60fb7cc978a8, rel=0x60fb7cca3c88, rti=1, rte=0x60fb7cc7b950) at /home/sven/projects/ts-pg16/src/planner/planner.c:1050
#17 0x00007d092ed979fb in timescaledb_set_rel_pathlist (root=0x60fb7cc978a8, rel=0x60fb7cca3c88, rti=1, rte=0x60fb7cc7b950) at /home/sven/projects/ts-pg16/src/planner/planner.c:1179
#18 0x000060fb7a7c7f20 in set_rel_pathlist (root=0x60fb7cc978a8, rel=0x60fb7cca3c88, rti=1, rte=0x60fb7cc7b950) at allpaths.c:561
#19 0x000060fb7a7c7a85 in set_base_rel_pathlists (root=0x60fb7cc978a8) at allpaths.c:373

Failing run: https://github.com/timescale/timescaledb/actions/runs/9048134054/job/24860858083

svenklemm avatar May 12 '24 14:05 svenklemm