Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fslQA-0006Tw-7x for pgsql-general@arkaria.postgresql.org; Thu, 23 Aug 2018 08:56:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fslQ8-0002oB-Dx for pgsql-general@arkaria.postgresql.org; Thu, 23 Aug 2018 08:56:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fslQ8-0002o4-5r for pgsql-general@lists.postgresql.org; Thu, 23 Aug 2018 08:56:48 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fslQ5-0000zm-7N for pgsql-general@postgresql.org; Thu, 23 Aug 2018 08:56:47 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id BC8D341486; Thu, 23 Aug 2018 10:56:43 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id gsbUw201zuGn; Thu, 23 Aug 2018 10:56:42 +0200 (CEST) Message-ID: Subject: Re: Command line session and running queries From: Laurenz Albe To: imp3 , "pgsql-general@postgresql.org" Date: Thu, 23 Aug 2018 10:56:41 +0200 In-Reply-To: <1109096000.1077136.1534928601221@mail.yahoo.com> References: <1109096000.1077136.1534928601221.ref@mail.yahoo.com> <1109096000.1077136.1534928601221@mail.yahoo.com> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk imp3 wrote: > I've run an update query inside command line tool (psql) then I've exit the tool (closing the window). > > When I re-logged in, I've noticed in pg_stat_activity that my query was still running. > I used the command pg_cancel_backend with the right PID, but it returned "f" few seconds later. > I re-checked pg_stat_activity and I was not able to see my query; there was only an autovacuum running on the table impacted by my query. > Since my update query usually takes about one hour, I was wandering what happened. > > Is postgres regularly checking command line session? If session has expired, would postgres stop the query and rollback it? > > I'm using both client and server v10.1. The query probably endet by itself between the point in time when you saw it in pg_stat_activity and when you tried to cancel it. The PostgreSQL backend will only notice that the client has died when it is done processing the query and tries to send an answer to the client. If that is a regular problem for you, you could set "statement_timeout" to put an upper limit on "runaway" queries. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com