Re: pgbench error: (setshell) of script 0; execution of meta-command failed

From: Andy Fan <zhihuifan1213(at)163(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench error: (setshell) of script 0; execution of meta-command failed
Date: 2025-01-10 07:09:52
Message-ID: 87ikqn5em7.fsf@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andy Fan <zhihuifan1213(at)163(dot)com> writes:

> Hi:
>
> I run into the {subject} issue with the below setup.
>
> cat foo.sql
>
> \setshell txn_mode echo ${TXN_MODE}
> \setshell speed echo ${SPEED}
> \setshell sleep_ms echo ${SLEEP_MS}
> \setshell subtxn_mode echo ${SUBTXN_MODE}
>
> select 1;
>
> $ TXN_MODE=-1 SPEED=1 SLEEP_MS=0 SUBTXN_MODE=-1 pgbench -n -ffoo.sql postgres -T5 -c4 --exit-on-abort
>
> I *randomly*(7/8) get errors like:
>
> pgbench (18devel)
> pgbench: error: client 2 aborted in command 0 (setshell) of script 0; execution of meta-command failed
> pgbench: error: Run was aborted due to an error in thread 0

I think I have figured out the issue, if you want reproduce it quicker,
you can change the '-T5' to '-T1' in the pgbench command and run many times.

Here is the patch to fix it, would someone take a look at?

pgbench: Avoid misleading error for \[set]shell when timer_exceeded.

fgets in executeMetaCommand may return NULL if it receives a signal
during the shell command is executing. Before this commit, pgbench
client raises ERROR like below.

pgbench: error: client 3 aborted in command 3 (setshell) of script 0;
execution of meta-command failed

This behavior is misleading since people may think something is
wrong. In this commit, we just ignore fgets return NULL when
timer_exceeded.

--
Best Regards
Andy Fan

Attachment Content-Type Size
0001-pgbench-Avoid-misleading-error-for-set-shell-when-ti.patch text/x-diff 1.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nazir Bilal Yavuz 2025-01-10 07:15:52 Re: Make pg_stat_io view count IOs as bytes instead of blocks
Previous Message jian he 2025-01-10 06:38:20 Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row