Re: [Proposal] Global temporary tables

From: wenjing <wjzeng2012(at)gmail(dot)com>
To: Andrew Bille <andrewbille(at)gmail(dot)com>
Cc: wenjing <wenjing(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tony Zhu <tony(dot)zhu(at)ww-it(dot)cn>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [Proposal] Global temporary tables
Date: 2021-10-09 07:41:26
Message-ID: CA+B_3V=OJr1NphoHOS7Yoyi4ANhoSco6EZw10QdEz+986zFw1Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Bille <andrewbille(at)gmail(dot)com> 于2021年10月7日周四 上午12:30写道:

> On master with the v54 patches applied the following script leads to crash:
>
Thank you for pointing it out.
This is a bug that occurs during transaction rollback and process exit, I
fixed it, please confirm it.

Wenjing

export
> ASAN_OPTIONS=detect_leaks=0:abort_on_error=1:disable_coredump=0:strict_string_checks=1:check_initialization_order=1:strict_init_order=1
> initdb -D data
> pg_ctl -w -t 5 -D data -l server.log start
> psql -c "create global temp table tmp_table_test_statistics(a int); insert
> into temp_table_test_statistics values(generate_series(1,1000000000));" &
> sleep 1
> pg_ctl -w -t 5 -D data -l server.log stop
>
> and i got error
> =================================================================
> ==1022892==ERROR: AddressSanitizer: heap-use-after-free on address
> 0x62500004c640 at pc 0x562435348750 bp 0x7ffee8487e60 sp 0x7ffee8487e50
> READ of size 8 at 0x62500004c640 thread T0
> ---
>
> with backtrace:
>
> Core was generated by `postgres: andrew regression [local] INSERT
> '.
> Program terminated with signal SIGABRT, Aborted.
> #0 __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
> (gdb) bt
> #0 __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> #1 0x00007fa8fd008859 in __GI_abort () at abort.c:79
> #2 0x000056243471eae2 in __sanitizer::Abort() ()
> #3 0x000056243472968c in __sanitizer::Die() ()
> #4 0x000056243470ad1c in
> __asan::ScopedInErrorReport::~ScopedInErrorReport() ()
> #5 0x000056243470a793 in __asan::ReportGenericError(unsigned long,
> unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned
> int, bool) ()
> #6 0x000056243470b5db in __asan_report_load8 ()
> #7 0x0000562435348750 in DropRelFileNodesAllBuffers
> (smgr_reln=smgr_reln(at)entry=0x62500004c640, nnodes=nnodes(at)entry=1) at
> bufmgr.c:3211
> #8 0x00005624353ec8a8 in smgrdounlinkall (rels=rels(at)entry=0x62500004c640,
> nrels=nrels(at)entry=1, isRedo=isRedo(at)entry=false) at smgr.c:397
> #9 0x0000562434aa76e1 in gtt_storage_removeall (code=<optimized out>,
> arg=<optimized out>) at storage_gtt.c:726
> #10 0x0000562435371962 in shmem_exit (code=code(at)entry=1) at ipc.c:236
> #11 0x0000562435371d4f in proc_exit_prepare (code=code(at)entry=1) at
> ipc.c:194
> #12 0x0000562435371f74 in proc_exit (code=code(at)entry=1) at ipc.c:107
> #13 0x000056243581e35c in errfinish (filename=<optimized out>,
> filename(at)entry=0x562435b800e0 "postgres.c", lineno=lineno(at)entry=3191,
> funcname=funcname(at)entry=0x562435b836a0 <__func__.26025>
> "ProcessInterrupts") at elog.c:666
> #14 0x00005624353f5f86 in ProcessInterrupts () at postgres.c:3191
> #15 0x0000562434eb26d6 in ExecProjectSet (pstate=0x62500003f150) at
> nodeProjectSet.c:51
> #16 0x0000562434eaae8e in ExecProcNode (node=0x62500003f150) at
> ../../../src/include/executor/executor.h:257
> #17 ExecModifyTable (pstate=0x62500003ec98) at nodeModifyTable.c:2429
> #18 0x0000562434df5755 in ExecProcNodeFirst (node=0x62500003ec98) at
> execProcnode.c:463
> #19 0x0000562434dd678a in ExecProcNode (node=0x62500003ec98) at
> ../../../src/include/executor/executor.h:257
> #20 ExecutePlan (estate=estate(at)entry=0x62500003ea20,
> planstate=0x62500003ec98, use_parallel_mode=<optimized out>,
> use_parallel_mode(at)entry=false, operation=operation(at)entry=CMD_INSERT,
> sendTuples=false, numberTuples=numberTuples(at)entry=0,
> direction=ForwardScanDirection,
> dest=0x625000045550, execute_once=true) at execMain.c:1555
> #21 0x0000562434dd9867 in standard_ExecutorRun (queryDesc=0x6190000015a0,
> direction=ForwardScanDirection, count=0, execute_once=execute_once(at)entry=true)
> at execMain.c:361
> #22 0x0000562434dd9a83 in ExecutorRun (queryDesc=queryDesc(at)entry=0x6190000015a0,
> direction=direction(at)entry=ForwardScanDirection, count=count(at)entry=0,
> execute_once=execute_once(at)entry=true) at execMain.c:305
> #23 0x0000562435401be6 in ProcessQuery (plan=plan(at)entry=0x625000045480,
> sourceText=0x625000005220 "insert into temp_table_test_statistics
> values(generate_series(1,1000000000));", params=0x0, queryEnv=0x0,
> dest=dest(at)entry=0x625000045550, qc=qc(at)entry=0x7ffee84886d0)
> at pquery.c:160
> #24 0x0000562435404a32 in PortalRunMulti (portal=portal(at)entry=0x625000020a20,
> isTopLevel=isTopLevel(at)entry=true, setHoldSnapshot=setHoldSnapshot(at)entry=false,
> dest=dest(at)entry=0x625000045550, altdest=altdest(at)entry=0x625000045550,
> qc=qc(at)entry=0x7ffee84886d0)
> at pquery.c:1274
> #25 0x000056243540598d in PortalRun (portal=portal(at)entry=0x625000020a20,
> count=count(at)entry=9223372036854775807, isTopLevel=isTopLevel(at)entry=true,
> run_once=run_once(at)entry=true, dest=dest(at)entry=0x625000045550,
> altdest=altdest(at)entry=0x625000045550, qc=<optimized out>)
> at pquery.c:788
> #26 0x00005624353fa917 in exec_simple_query
> (query_string=query_string(at)entry=0x625000005220 "insert into
> temp_table_test_statistics values(generate_series(1,1000000000));") at
> postgres.c:1214
> #27 0x00005624353ff61d in PostgresMain (dbname=dbname(at)entry=0x629000011278
> "regression", username=username(at)entry=0x629000011258 "andrew") at
> postgres.c:4497
> #28 0x00005624351f65c7 in BackendRun (port=port(at)entry=0x615000002d80) at
> postmaster.c:4560
> #29 0x00005624351ff1c5 in BackendStartup (port=port(at)entry=0x615000002d80)
> at postmaster.c:4288
> #30 0x00005624351ff970 in ServerLoop () at postmaster.c:1801
> #31 0x0000562435201da4 in PostmasterMain (argc=3, argv=<optimized out>) at
> postmaster.c:1473
> #32 0x0000562434f3ab2d in main (argc=3, argv=0x603000000280) at main.c:198
> ---
>
> I've built the server with sanitizers using gcc 9 as following:
> CPPFLAGS="-Og -fsanitize=address -fsanitize=undefined
> -fno-sanitize=nonnull-attribute -fno-sanitize-recover
> -fno-sanitize=alignment -fstack-protector" LDFLAGS='-fsanitize=address
> -fsanitize=undefined -static-libasan' ./configure --enable-tap-tests
> --enable-debug
>
>

Attachment Content-Type Size
0004-gtt-v55-regress.patch application/octet-stream 79.1 KB
0003-gtt-v55-implementation.patch application/octet-stream 164.8 KB
0001-gtt-v55-reademe.patch application/octet-stream 7.5 KB
0002-gtt-v55-doc.patch application/octet-stream 7.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shay Rojansky 2021-10-09 08:01:25 starts_with, ^@ and index usage
Previous Message Mark Dilger 2021-10-08 22:30:47 Re: Role Self-Administration