Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tW99m-00EXXB-O6 for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jan 2025 07:10:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tW99j-00CuTi-MR for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jan 2025 07:10:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tW99i-00CuNH-Jr for pgsql-hackers@lists.postgresql.org; Fri, 10 Jan 2025 07:10:06 +0000 Received: from m16.mail.163.com ([220.197.31.3]) by magus.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1tW99b-000rss-09 for pgsql-hackers@postgresql.org; Fri, 10 Jan 2025 07:10:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version: Content-Type; bh=hS43L9UEHYL2p8EtzQXJ95ajZFDAEwuwzKCOsTfVjac=; b=XV1Ll3O/5eW1W+nWjGjibLIcDjxMdePlH3Nh4HYVMDWgLIzNVJUHcpL40wccok 1UK5Oe4j+0T288Bzsa6xEfGaOzJOXc0gn1ShTodYMOuMFhd/LzXG/7JPj/pFE0iw jb2D6NQsc5KH3N2SODSbWI6hn/XeoOfoyApwV0cVSq9sA= Received: from lovely-coding (unknown []) by gzga-smtp-mtada-g1-2 (Coremail) with SMTP id _____wDnr5bAx4BnoqGaFA--.15799S3; Fri, 10 Jan 2025 15:09:52 +0800 (CST) From: Andy Fan To: pgsql-hackers Subject: Re: pgbench error: (setshell) of script 0; execution of meta-command failed In-Reply-To: <87msfz5qv2.fsf@163.com> (Andy Fan's message of "Fri, 10 Jan 2025 02:45:21 +0000") References: <87msfz5qv2.fsf@163.com> Date: Fri, 10 Jan 2025 07:09:52 +0000 Message-ID: <87ikqn5em7.fsf@163.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-CM-TRANSID:_____wDnr5bAx4BnoqGaFA--.15799S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7WrW3Gr18uF1DJr4UJr47urg_yoW8Gr47pa n3Kw1Ut340vFy8Jr1DZrWxZa40vrn09Fy5Jr1UGr9rGwnxX3W2krZa9a98ua42gr4xtwnI qFyvywsxZFZ3AFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0z_hL0AUUUUU= X-Originating-IP: [219.151.179.207] X-CM-SenderInfo: x2klx3xlid0iqsrtqiywtou0bp/xtbBzwDQU2eAP1uYKgAAs9 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain Andy Fan 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-pgbench-Avoid-misleading-error-for-set-shell-when-ti.patch From 9b03ff66e45d019631ed9fd3322c0911ce14a8a7 Mon Sep 17 00:00:00 2001 From: Andy Fan Date: Fri, 10 Jan 2025 06:56:11 +0000 Subject: [PATCH 1/1] 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. --- src/bin/pgbench/pgbench.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index c415e0f32c..7f61cd3aea 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3851,7 +3851,9 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg) Assert(st->state == CSTATE_WAIT_RESULT || st->state == CSTATE_END_COMMAND || st->state == CSTATE_SLEEP || - st->state == CSTATE_ABORTED); + st->state == CSTATE_ABORTED || + st->state == CSTATE_FINISHED); + break; /* @@ -4414,6 +4416,8 @@ executeMetaCommand(CState *st, pg_time_usec_t *now) { if (!runShellCommand(&st->variables, argv[1], argv + 2, argc - 2)) { + if (timer_exceeded) + return CSTATE_FINISHED; commandFailed(st, "setshell", "execution of meta-command failed"); return CSTATE_ABORTED; } @@ -4422,6 +4426,8 @@ executeMetaCommand(CState *st, pg_time_usec_t *now) { if (!runShellCommand(&st->variables, NULL, argv + 1, argc - 1)) { + if (timer_exceeded) + return CSTATE_FINISHED; commandFailed(st, "shell", "execution of meta-command failed"); return CSTATE_ABORTED; } -- 2.45.1 --=-=-=--