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 1pHRIk-00064U-5d for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Jan 2023 15:21:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pHRIj-0007Ww-01 for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Jan 2023 15:21:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHRIi-0007Wn-1j for pgsql-bugs@lists.postgresql.org; Mon, 16 Jan 2023 15:21:32 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pHRIf-0000T7-CW for pgsql-bugs@lists.postgresql.org; Mon, 16 Jan 2023 15:21:31 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 56CEC32002D8; Mon, 16 Jan 2023 10:21:27 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 16 Jan 2023 10:21:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673882486; x=1673968886; bh=LiuJoJDRLZe5r g1vxZB1LVUK74ezi08aOFW/xAriEOc=; b=HT0+TsSOkEUduIVBjPWDgoI/EneU6 VxKWxUBg1o85ixc8I/Uxbadqv2MeVX58OoBApGsfSrHGFGJpDSEw+Qb34Od6aWkj 6r+It0hVTyYk0rBK4VPlLycEEPOIJw545EmFu/EcfmN5rxsiF7NDxhh0vuOciZ8T kMS9sLdt92QEWfCvKzfsaGqWgpHpzmyJVG8d39q4M1zoIXCSBmukdGHsN9hENtvk kTKNZZsXYZZu0KX3X32zq+wvxQEWDgdjR3HzHBU/rIe8betb9H+I05Y4ffROLhR3 P+ohYVfYiCcZvO2FyP8j04eLN7RctPkRXnsl5Qn+Eu9pNwCxIJn4a63Bg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddtgedgjeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkgggtugfgjgesthekre dttddtjeenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgv segrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepudejveejffejve duudetvdekieeuiedtvdeileefkeevjedufeeguedvjefhueelnecuffhomhgrihhnpegv nhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 16 Jan 2023 10:21:26 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 8F60797; Mon, 16 Jan 2023 16:14:59 +0100 (CET) Date: Mon, 16 Jan 2023 16:14:59 +0100 From: Alvaro Herrera To: dastapov@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17698: On SIGTERM, psql terminates, but leaves the statement running Message-ID: <20230116151459.fzg6mlegkcrzch4i@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <17698-58a6ab8caec496b0@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Nov-25, PG Bug reporting form wrote: > Reproduction: start psql, launch a query that will take a while (I > used 'select pg_sleep(1234)'), then from another terminal do > "kill -TERM ". Psql would be terminated, but query would > not be, and will keep running until TCP timeout kicks in and kills the > stale connection. > > SIGINT, on the other hand, will cause psql will terminate the current > statement. > > Perhaps psql could have a SIGTERM handler that does roughly what > SIGINT handler does before terminating the whole process, and would > cancel the current statement (if any)? Sure. I doubt we want to wait until a reply to the cancel request is obtained, but we could have the sigterm handler at least send it before terminating. Why do you send SIGTERM to psql anyway? -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end." (2nd Commandment for C programmers)