Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBOdT-0007Nk-M8 for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Jun 2023 23:50:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qBOcU-0000I7-7Y for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Jun 2023 23:49:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBOcT-0000Hj-Ob for pgsql-hackers@lists.postgresql.org; Mon, 19 Jun 2023 23:49:13 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qBOcO-003W87-Ru for pgsql-hackers@postgresql.org; Mon, 19 Jun 2023 23:49:11 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-553b2979fceso832051a12.3 for ; Mon, 19 Jun 2023 16:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=neon-tech.20221208.gappssmtp.com; s=20221208; t=1687218546; x=1689810546; h=in-reply-to:references:subject:cc:from:to:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0QNU0J7jFxqchd7KNOX/Nh18KPEBpLXIZZ6gDsDX9Ac=; b=w1x//9ykDu1nY99Xjrrrzdhu3LJdRSZh7NOMr173Cu+UAiucTfDpw6vlxhXFTqEan5 Qa01RBDGrChWoe2iwFcxJRHkn6oH/pQ9NkIEqyG0gQP56qIIXo15vxD25PEI13hiohnp 1BrqSnwBFOO3xZ6TB1KFuHvRUWflKQQVX6/WntF26VlJ/phvrWfclKp1cNN13wUOoKMy 06sxOew0n9ZhfL3wgXifUIW6EOtJ5lXRMBkqzD8WqmAqHPObD9GsAH6ehIW1A+jWvUS7 ixbkgbR1mXqNMHI259ZS8XrOkwdMB70/JLDS5bAP70jtFLsCeTCcPZE1G42wk9NwWKkL j8gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687218546; x=1689810546; h=in-reply-to:references:subject:cc:from:to:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=0QNU0J7jFxqchd7KNOX/Nh18KPEBpLXIZZ6gDsDX9Ac=; b=MtY6j8PL9M5NUmN4CWG+rUH5CTtI6eMH/HIo6bwFS4wkLxk+p+A3MlvmsXuczBtD/9 lsFotaFyPdlZiu45wSAl5pGR1Y9hyll9gz/wEpUyKPpNoXncG0zMh6k/1Jd49TRSUFKR TEoUeGcpYzrcLakmaJZYO+aQdY6dHneDe91Z81xmXI6w2xz6fSpWI1AnrD5u0EF6IOcN 9CpL/K5AxpDHGDInjG+tTl6mvJvHEkm1k5A7mEO8ZIeQrgPEpRx8XoMbc6tJGkwBX8ox Z7QNJQ6WttQS++wMc+fGz8Ygl5XLvJECdFrqabxn4ftsg93/FRKlGrM64vjAaG/A+uH3 c5TQ== X-Gm-Message-State: AC+VfDzhoVgHFHWK84NUq7MNh4cDqlpXNm7IV4YhdpHHUsICMjfCVRdJ p69cfjXZQjxemwBjZiVSi4gSHNOLFvDdoUxEQAk= X-Google-Smtp-Source: ACHHUZ588E+1vAA++m44mQPw6+Kkg/cotcjKbcqPHcBzLqy5vvOm57XL0+uJU5RKm5QudqWXVdBh4A== X-Received: by 2002:a05:6a20:7f82:b0:11a:efaa:eb43 with SMTP id d2-20020a056a207f8200b0011aefaaeb43mr12168691pzj.3.1687218546463; Mon, 19 Jun 2023 16:49:06 -0700 (PDT) Received: from localhost ([50.204.37.254]) by smtp.gmail.com with ESMTPSA id w15-20020a170902e88f00b001b01547d0e8sm333102plg.142.2023.06.19.16.49.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Jun 2023 16:49:06 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 19 Jun 2023 16:49:05 -0700 Message-Id: To: "Yugo NAGATA" From: "Tristan Partin" Cc: "Michael Paquier" , Subject: Re: Make pgbench exit on SIGINT more reliably X-Mailer: aerc 0.15.2-52-g8e0cc222e2c9 References: <20230619223937.209ff5c4c295da2fbb4adaa0@sraoss.co.jp> In-Reply-To: <20230619223937.209ff5c4c295da2fbb4adaa0@sraoss.co.jp> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon Jun 19, 2023 at 6:39 AM PDT, Yugo NAGATA wrote: > On Wed, 24 May 2023 08:58:46 -0500 > "Tristan Partin" wrote: > > > On Tue May 23, 2023 at 7:31 PM CDT, Michael Paquier wrote: > > > On Mon, May 22, 2023 at 10:02:02AM -0500, Tristan Partin wrote: > > > > The way that pgbench handled SIGINT changed in > > > > 1d468b9ad81b9139b4a0b16b416c3597925af4b0. Unfortunately this had a > > > > couple of unintended consequences, at least from what I can tell[1]= . > > > >=20 > > > > - CTRL-C no longer stops the program unless the right point in pgbe= nch > > > > execution is hit=20 > > > > - pgbench no longer exits with a non-zero exit code > > > >=20 > > > > An easy reproduction of these problems is to run with a large scale > > > > factor like: pgbench -i -s 500000. Then try to CTRL-C the program. > > > > > > This comes from the code path where the data is generated client-side= , > > > and where the current CancelRequested may not be that responsive, > > > isn't it? > >=20 > > It comes from the fact that CancelRequested is only checked within the > > generation of the pgbench_accounts table, but with a large enough scale > > factor or enough latency, say cross-continent communication, generating > > the other tables can be time consuming too. But, yes you are more likel= y > > to run into this issue when generating client-side data. > > If I understand correctly, your patch allows to exit pgbench immediately > during a client-side data generation even while the tables other than > pgbench_accounts are processed. It can be useful when the scale factor > is large. However, the same purpose seems to be achieved by you other pat= ch [1]. > Is the latter your latest proposal that replaces the patch in this thread= ?ad? > > [1] https://www.postgresql.org/message-id/flat/CSTU5P82ONZ1.19XFUGHMXHBRY= %40c3po The other patch does not replace this one. They are entirely separate. > Also, your proposal includes to change the exit code when pgbench is canc= elled by > SIGINT. I think it is nice because this will make it easy to understand a= nd clarify=20 > the result of the initialization.=20 > > Currently, pgbench returns 0 when the initialization is cancelled while p= opulating > pgbench_branches or pgbench_tellers, but the resultant pgbench_accounts h= as only > one row, which is an inconsistent result. Returning the specific value fo= r SIGINT > cancel can let user know it explicitly. In addition, it seems better if a= n error > message to inform would be output.=20 > > For the above purpose, the patch moved exit codes of psql to fe_utils to = be shared. > However, I am not sure this is good way. Each frontend-tool may have it = own exit code, > for example. "2" means "bad connection" in psql [2], but "errors during t= he run" in > pgbench [3]. So, I think it is better to define them separately. > > [2] https://www.postgresql.org/docs/current/app-psql.html#id-1.9.4.20.7 > [3] https://www.postgresql.org/docs/current/pgbench.html#id=3Did-1.9.4.11= .7 I can change it. I just figured that sharing exit code definitions would've been preferrable. I will post a v3 some time soon which removes that patch. Thanks for your review :). --=20 Tristan Partin Neon (https://neon.tech)