Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error
Alexander Law <exclusion@gmail.com>
From: Alexander Lakhin <exclusion@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Yugo NAGATA <nagata@sraoss.co.jp>, Andres Freund <andres@anarazel.de>,
Tom Lane <tgl@sss.pgh.pa.us>, Fabien COELHO <coelho@cri.ensmp.fr>,
pgsql-hackers@postgresql.org
Date: 2023-05-20T16:00:01Z
Lists: pgsql-hackers
Hello Alvaro, 21.02.2023 19:32, Alvaro Herrera wrote: > On 2023-Feb-20, Alvaro Herrera wrote: > >> Found one last problem: if you do "-f foobar.sql -M prepared" in that >> order, then the prepare fails because the statement names would not be >> assigned when the file is parsed. This coding only supported doing >> "-M prepared -f foobar.sql", which funnily enough is the only one that >> PostgreSQL/Cluster.pm->pgbench() supports. So I moved the prepared >> statement name generation to the postprocess step. > Pushed to all three branches -- thanks, Nagata-san, for diagnosing the > issue. Starting from 038f586d5, the following script: echo " \startpipeline \endpipeline " >test.sql pgbench -n -M prepared -f test.sql leads to the pgbench's segfault: Core was generated by `pgbench -n -M prepared -f test.sql'. Program terminated with signal SIGSEGV, Segmentation fault. warning: Section `.reg-xstate/2327306' in core file too small. #0 0x0000555a402546b4 in prepareCommandsInPipeline (st=st@entry=0x555a409d62e0) at pgbench.c:3130 3130 st->prepared[st->use_file][st->command] = true; (gdb) bt #0 0x0000555a402546b4 in prepareCommandsInPipeline (st=st@entry=0x555a409d62e0) at pgbench.c:3130 #1 0x0000555a40257fca in executeMetaCommand (st=st@entry=0x555a409d62e0, now=now@entry=0x7ffdd46eff58) at pgbench.c:4413 #2 0x0000555a402585ce in advanceConnectionState (thread=thread@entry=0x555a409d6580, st=st@entry=0x555a409d62e0, agg=agg@entry=0x7ffdd46f0090) at pgbench.c:3807 #3 0x0000555a40259564 in threadRun (arg=arg@entry=0x555a409d6580) at pgbench.c:7535 #4 0x0000555a4025ca40 in main (argc=<optimized out>, argv=<optimized out>) at pgbench.c:7253 Best regards, Alexander
Commits
-
Fix pgbench in prepared mode with an empty pipeline
- 8f5e42d33469 16.0 landed
- 34f51196573c 15.4 landed
-
pgbench: Prepare commands in pipelines in advance
- 663e50e83211 14.8 landed
- 108a22bd14d4 15.3 landed
- 038f586d5f1d 16.0 landed
-
Add -M (query mode) option per ITAGAKI Takahiro
- 49639a7b2c52 8.4.0 cited