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 1lPljQ-0001ub-Qk for pgsql-admin@arkaria.postgresql.org; Fri, 26 Mar 2021 12:38:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lPljN-000146-VB for pgsql-admin@arkaria.postgresql.org; Fri, 26 Mar 2021 12:38:25 +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 1lPljN-00013t-Ch for pgsql-admin@lists.postgresql.org; Fri, 26 Mar 2021 12:38:25 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lPljJ-0000iA-L0 for pgsql-admin@lists.postgresql.org; Fri, 26 Mar 2021 12:38:23 +0000 Received: by mail-ej1-x62a.google.com with SMTP id u9so8169722ejj.7 for ; Fri, 26 Mar 2021 05:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=tEVmLdzDi+oLg8rF/xnK/gMOg7EMkWb7yH0eEEq8ERI=; b=WiT9UgzwS/6SJUWN5CXZTZIJ4bU5V6JgIA9Larx1HWIu38K/wt6eRm0whDNmt7L67k 0mu4eaDrWDJ4ALeGUlVii1/98o0vDhgwgbLUW4ut6ILrYJr5LgDAMgt5xzFiHQSpXkV7 cwikXtnGrnUXOyItAgDWEiIT0XSzZHvOvQpqHC72X/rrKfXJ0UfpiB1SQ0F+zK4VdixD 0va7ZriHuQbrI9uwEjMPcPrTSzTusAQfJj+jQ1G9TkaXXWrJwK7fky4Irf2fJBLKUBX/ Iarka5TGbnZ4fi3TqhLvbh8PvDq+BZHX1GYz3AdStvD9vgdqiNINjBaaHxBSgxIUtGX9 9NmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=tEVmLdzDi+oLg8rF/xnK/gMOg7EMkWb7yH0eEEq8ERI=; b=HfaWrleaEC2n+h2fz9fMqGcVbZa+zmJVUaKnkYhuEnETgiWPQGBJPgI2ZnmqYYx2u3 MEWZB1wDfMMfupQ4MP4qoHZhnfI4eLekilCob5ai+DR+ktTUzw0+n6uvOE3NNQM5863m pjuccZUafxPaUqTfM1oMl34+Fb/f4yZLw61MEX2QYv8lJSQ89DMtFQa3efVIz0x3o5ud Gy6WkrSbbon+2Lff/frCrPpEvfxbgt3tvZG90G2yf007YHT1Bl+Ock0di68u10ReRntt RtNo760Vyq2VJh49Va6ytPurAEFNKAbgxWRIdpKTqBT64uHiVlsBEBxIokigdx27lxM6 VEzg== X-Gm-Message-State: AOAM530OamFzdJCE4f/wo7T49W1+X0Ol4MV5sfwm9JM/ZevNRqPjbYZY aIwR6CoRb2oGm3Y5ofEXNH4kgA== X-Google-Smtp-Source: ABdhPJwrTD1+h7UdZsfjY/mRBr5fCMNA1AyRlUPmrIcTspwbdPHg0MBbPzRbL3WX0EMREVOrgXazJw== X-Received: by 2002:a17:906:3385:: with SMTP id v5mr15176126eja.539.1616762299536; Fri, 26 Mar 2021 05:38:19 -0700 (PDT) Received: from localhost.localdomain (217-149-169-173.nat.highway.telekom.at. [217.149.169.173]) by smtp.gmail.com with ESMTPSA id a26sm4347534edm.15.2021.03.26.05.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Mar 2021 05:38:19 -0700 (PDT) Message-ID: Subject: Re: Old query lying around in pg_stat_activity for weeks From: Laurenz Albe To: Julien Rouhaud , Jacque Edmund Cc: "pgsql-admin@lists.postgresql.org" Date: Fri, 26 Mar 2021 13:38:18 +0100 In-Reply-To: <20210326112528.6uiso3o2fgk73rqg@nol> References: <20210326112528.6uiso3o2fgk73rqg@nol> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2021-03-26 at 19:25 +0800, Julien Rouhaud wrote: > On Fri, Mar 26, 2021 at 07:16:42AM -0400, Jacque Edmund wrote: > > Was alerted to an old query lying around in the pg_stat_activity view on a > > little used server recently. It ha no values for wait_event_type or > > wait_event and had an idle state value. The query_start value was about > > two weeks old. Odd, but after verifying it had no pg_lock lookup, I > > canceled it. > > > > Might there be an infrequent staleness of items that appear in the > > pg_stat_activity view that is just understood to be there from time to time? > > If the state is "idle" it means it's only a connection doing nothing, it's not > really consuming any resources. You also can't cancel it, since it isn't doing > anything, just close it. > > The best thing to do if you don't have persistent connections or a connection > pooler is to check where the connection coming from and investigate what could > be the client/application responsible for leaking an idle connection. I guess Jacque is confused by the "query" column. It does not necessarily show a query that is currently running, it just shows the most recent query in the session. If "state" is "idle", the query is already finished. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com