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 1lPkaa-0007HS-Vl for pgsql-admin@arkaria.postgresql.org; Fri, 26 Mar 2021 11:25:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lPkaY-0002rk-Q4 for pgsql-admin@arkaria.postgresql.org; Fri, 26 Mar 2021 11:25: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 1lPkaY-0002rB-Fy for pgsql-admin@lists.postgresql.org; Fri, 26 Mar 2021 11:25:14 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lPkaP-0003Ei-FS for pgsql-admin@lists.postgresql.org; Fri, 26 Mar 2021 11:25:11 +0000 Received: by mail-pj1-x102d.google.com with SMTP id q6-20020a17090a4306b02900c42a012202so2311198pjg.5 for ; Fri, 26 Mar 2021 04:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lU3OU9UJTUvNxeuHsTZFHMPzC+lHQQ+EbEt2cMosdRM=; b=hNtf+p+TH94H+TJ06wKgYgO8+wv8hBE2SNH3vf94Wn+k9XPHyU0CMQ5oQu3CBbdyiQ ZZisOkSmNinKN7hxFAcERSp38dwpnZHNuHtkxAksqm9JjwHzS9uuyrIL76IKrYXfx1mG j/zZ3M7WIPTelUjSiW2Hh8ywvzQEGEi9TV9lw+FYY1KtCawiqZ17+Ik7MeKhkKFyxKr4 Yj3sRF0S/LupQj14qYowBveSiKn7nUBchty2ckgeDGG5bwMnvNRT7DZSpZiSF8hx5oXp sGtjv16aQQU3Gep3d8epFpXSYrWVxq/NTzS96mt9LLSymMSFnQKVKxQTNYuNvTBMMSgN uMZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lU3OU9UJTUvNxeuHsTZFHMPzC+lHQQ+EbEt2cMosdRM=; b=Y3t5ENpl8Kctu2SBfrW1l+PtzSyhMsKiTy8WSnZNfEPXIg1sLBpNCktZbV9qrtCVEF nm/ASco+UaI72vVqWTR2HhD0jj6b+VBAbdE3uhY616SdnfJLd0XfuaWNc28a/IRfHU+B XTzow8ZuxVyDlSTZB+4EzkfUSJdN5lF2VGZyNrEqzUrwPRwpayb7ZWel3+ZqyaJNq+Y+ T8lz1OO/Aw00nM7XEMbAUYSynj32nQ5j/0XhESOkQbsTpXQJyEby68pHI098L+QGddle g+KoIN5UMVhD67Ci+Kh1H2aMePOF52Or/YTWg9wc3Th46hZZP8opq97KBfgmVNeklnZi fC+w== X-Gm-Message-State: AOAM5327k0nQGEWJnDR0OyJ8G+QPB+DZJnIMcBdNwW1bjSKwZRR25gq1 rS9zZt9BIkY51JZ+3mSphWA= X-Google-Smtp-Source: ABdhPJyfrGXJoYahY4oIvmiSJPgC6PCcc8G+kpSyfREZe3DNVza1jybRdmE0w7fKfSoknjY67fYGTA== X-Received: by 2002:a17:90b:3909:: with SMTP id ob9mr13812548pjb.181.1616757902718; Fri, 26 Mar 2021 04:25:02 -0700 (PDT) Received: from nol (2001-b011-0008-5a94-87c0-1014-431f-3df2.dynamic-ip6.hinet.net. [2001:b011:8:5a94:87c0:1014:431f:3df2]) by smtp.gmail.com with ESMTPSA id w23sm2285760pgi.63.2021.03.26.04.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Mar 2021 04:25:02 -0700 (PDT) Date: Fri, 26 Mar 2021 19:25:28 +0800 From: Julien Rouhaud To: Jacque Edmund Cc: "pgsql-admin@lists.postgresql.org" Subject: Re: Old query lying around in pg_stat_activity for weeks Message-ID: <20210326112528.6uiso3o2fgk73rqg@nol> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.