Mooncake-Labs / pg_mooncake

Iceberg/Delta Columnstore Table in Postgres
http://mooncake.dev
MIT License
207 stars 11 forks source link

Server crashes when executing "execute test_mode_pp(1)" #19

Open saygoodbyye opened 1 week ago

saygoodbyye commented 1 week ago

What happens?

Server crashes when executing the script below PostgreSQL build:

CFLAGS='-Og' ./configure --enable-tap-tests --with-openssl --enable-debug --enable-cassert --with-icu --with-lz4 --with-libxml

To Reproduce

create extension pg_mooncake;
create table test_mode (a int) USING columnstore;
prepare test_mode_pp (int) as select count(*) from test_mode where a = $1;
set plan_cache_mode to force_generic_plan;
explain (costs off) execute test_mode_pp(2);
execute test_mode_pp(1);

backtrace:

#0  heap_compute_data_size (tupleDesc=tupleDesc@entry=0x61b8c0754648, values=values@entry=0x61b8c07547a0, isnull=isnull@entry=0x61b8c07547b0) at ../../../../src/include/postgres.h:314
#1  0x000061b8befbbbfb in heap_form_minimal_tuple (tupleDescriptor=0x61b8c0754648, values=0x61b8c07547a0, isnull=0x61b8c07547b0) at heaptuple.c:1492
#2  0x000061b8bf1c9570 in tts_virtual_copy_minimal_tuple (slot=<optimized out>) at execTuples.c:305
#3  0x000061b8bf528363 in ExecCopySlotMinimalTuple (slot=<optimized out>) at ../../../../src/include/executor/tuptable.h:494
#4  tuplestore_puttupleslot (state=0x61b8c070d830, slot=<optimized out>) at tuplestore.c:717
#5  0x000061b8bf2049f8 in tstoreReceiveSlot_notoast (slot=<optimized out>, self=<optimized out>) at tstoreReceiver.c:126
#6  0x000061b8bf1bdd32 in ExecutePlan (estate=estate@entry=0x61b8c0754110, planstate=0x61b8c0754358, use_parallel_mode=<optimized out>, operation=operation@entry=CMD_SELECT, sendTuples=sendTuples@entry=true, numberTuples=numberTuples@entry=0,
    direction=ForwardScanDirection, dest=0x61b8c0725738, execute_once=true) at execMain.c:1685
#7  0x000061b8bf1bea3e in standard_ExecutorRun (queryDesc=0x61b8c07157b0, direction=ForwardScanDirection, count=0, execute_once=true) at execMain.c:365
#8  0x000061b8bf1beb7f in ExecutorRun (queryDesc=queryDesc@entry=0x61b8c07157b0, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=<optimized out>) at execMain.c:306
#9  0x000061b8bf3a27a2 in PortalRunSelect (portal=portal@entry=0x61b8c069c370, forward=forward@entry=true, count=0, count@entry=9223372036854775807, dest=dest@entry=0x61b8c0725738) at pquery.c:924
#10 0x000061b8bf3a3ff2 in PortalRun (portal=portal@entry=0x61b8c069c370, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=false, run_once=run_once@entry=true, dest=dest@entry=0x61b8c0725738, altdest=altdest@entry=0x61b8c0725738,
    qc=0x7ffe59991070) at pquery.c:768
#11 0x000061b8bf15aaec in ExecuteQuery (pstate=pstate@entry=0x61b8c07257c8, stmt=stmt@entry=0x61b8c0610a18, intoClause=intoClause@entry=0x0, params=params@entry=0x0, dest=dest@entry=0x61b8c0725738, qc=qc@entry=0x7ffe59991070) at prepare.c:255
#12 0x000061b8bf3a5d0a in standard_ProcessUtility (pstmt=0x61b8c0610ac8, queryString=0x61b8c060ffb0 "execute test_mode_pp(1);", readOnlyTree=<optimized out>, context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x61b8c0725738,
    qc=0x7ffe59991070) at utility.c:750
#13 0x000061b8bf3a631e in ProcessUtility (pstmt=pstmt@entry=0x61b8c0610ac8, queryString=<optimized out>, readOnlyTree=<optimized out>, context=context@entry=PROCESS_UTILITY_TOPLEVEL, params=<optimized out>, queryEnv=<optimized out>,
    dest=0x61b8c0725738, qc=0x7ffe59991070) at utility.c:519
#14 0x000061b8bf3a3865 in PortalRunUtility (portal=portal@entry=0x61b8c069c260, pstmt=0x61b8c0610ac8, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=true, dest=dest@entry=0x61b8c0725738, qc=qc@entry=0x7ffe59991070)
    at pquery.c:1158
#15 0x000061b8bf3a3cc1 in FillPortalStore (portal=portal@entry=0x61b8c069c260, isTopLevel=isTopLevel@entry=true) at pquery.c:1031
#16 0x000061b8bf3a4038 in PortalRun (portal=portal@entry=0x61b8c069c260, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x61b8c0610e88, altdest=altdest@entry=0x61b8c0610e88,
    qc=0x7ffe59991260) at pquery.c:763
#17 0x000061b8bf3a00fe in exec_simple_query (query_string=query_string@entry=0x61b8c060ffb0 "execute test_mode_pp(1);") at postgres.c:1278
#18 0x000061b8bf3a203e in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4767
#19 0x000061b8bf39b63c in BackendMain (startup_data=<optimized out>, startup_data_len=<optimized out>) at backend_startup.c:105
#20 0x000061b8bf2f5dc8 in postmaster_child_launch (child_type=child_type@entry=B_BACKEND, startup_data=startup_data@entry=0x7ffe59991484 "", startup_data_len=startup_data_len@entry=4, client_sock=client_sock@entry=0x7ffe599914c0)
    at launch_backend.c:277
#21 0x000061b8bf2fa4c3 in BackendStartup (client_sock=client_sock@entry=0x7ffe599914c0) at postmaster.c:3593
#22 0x000061b8bf2fa73d in ServerLoop () at postmaster.c:1674
#23 0x000061b8bf2fbdaf in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x61b8c05ca010) at postmaster.c:1372
#24 0x000061b8bf21d61b in main (argc=3, argv=0x61b8c05ca010) at main.c:197

OS:

Ubuntu 24.04

pg_mooncake Version:

acda6eeb4c719d280d2ee324ef8a29644f9446fa

Postgres Version:

REL_17_STABLE

Are you using pg_mooncake Docker, Neon, or the extension standalone?

pg_mooncake extension standalone

Best regards, Egor Chindyaskin Postgres Professional: https://postgrespro.com/

dpxcc commented 1 week ago

Thank you for reporting this bug! We've filed it upstream for resolution https://github.com/duckdb/pg_duckdb/issues/410