Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vHNqj-005aBh-G6 for pgsql-general@arkaria.postgresql.org; Fri, 07 Nov 2025 14:54:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vHNqi-00EjvW-6V for pgsql-general@arkaria.postgresql.org; Fri, 07 Nov 2025 14:54:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vHNqh-00EjvO-Od for pgsql-general@lists.postgresql.org; Fri, 07 Nov 2025 14:53:59 +0000 Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vHNqg-005v47-0L for pgsql-general@postgresql.org; Fri, 07 Nov 2025 14:53:58 +0000 Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-65366485678so377980eaf.2 for ; Fri, 07 Nov 2025 06:53:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762527237; x=1763132037; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=Qx0VGdBGLUovylcqSFFS1SToNVg4BTNntviaHiQ7ZU4=; b=eyKdf8+pom2HnKI+HeA8Oh2Ngciqzql3AshAfY48UteCKHn+ut0l0A4jpnm/COcWSf cjtUTRHMi83UhqyrFkH2xi8KwhOgsUrrniXNeknH7ZtdDR8WJrMtK6kayA2f2d0jtrD5 SWzW0cxEaBHd8pugjk6JZUUNEkTcrG0Fw6nGsZMl7BbHay7K+YxBPKLKGfTJ70euc8l6 pALUiDFxvlGRNtV+xGZ1MMTWK+85BRbJ9CqEAzjE4T/YoMnofpUd282Ik1gFDGoNUEc6 5paZv09UJwAP/lJbpi9PEGZEBYNP5ZzsmXb3WbIMcacskaCwyFT9iNur0/xqdPTKTBz5 kZxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762527237; x=1763132037; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Qx0VGdBGLUovylcqSFFS1SToNVg4BTNntviaHiQ7ZU4=; b=aXdo9ucuxv0pxTMb6teswKR+VqzPALOA91OYXdW2GXWHLt2zukczK5H3IzJyulOowW dh9fl4i523HPm0EMUFPOy/LGNPSftDuv4xTVcVzG+8CNbwLON2SUtaGiioPk19S1NUyL K9Kt/ri2ToXA2WC9wrdjaxiTjTchHO0PzrY2A2zQ9VAUqr4SqtAxvppqNJG9ZudrilQJ XrOa+G0tpg4f4TLT/Wf4HavwAwR5YT5Q1PwWWYzvYXwHXO2xufw8skOQ2ZwZeDw7TXSy S54PfEeH68Fs8YnlBjvQysLXFedSHARhLXJniistEnLzyvrWfrWI3zetVyOvqijgCONZ ol0A== X-Gm-Message-State: AOJu0YwuguN5nWSQPP1YeECOSg3ggf/dKaH2F8TY2WYi5FvdAxuXjCNw bzKf6k5dCpZSeVnO85cqCVvxVr7qfegWitFmuI2lkn+p/8LP/TYzn46GpC1vsJDFVUiEssL+Cd4 E32Ktg1pRCOdlfXdPJ8H6jFTQ0O/87l+ekQ== X-Gm-Gg: ASbGncswYgywDDKtyw3MvjOKYVDRteAVQv0LvE6rF3XTBqQXMQpq+kQHx2oZalrf55X 4nX0CHNMJNTl7iYXTDgG4MYMW5zOwqNZtyCdbeRD6Fe8O8KDbz6zEI3TWRoJIBO4Q4JRSHaikNf U/5CWW5Q2Vs1fdVeivc3Nsg82xb49WWOcnrDofuoCa2IOkHDArXqbrr5Xpzm1MSu9hNosUrX4zP GCa1E4+VIRk/cWJHVyOjv+AKuyPnOh03mJVnN6tNjQMS5LNZvF0lk4Xp4Z2cVyZfVnRTdqD X-Google-Smtp-Source: AGHT+IE2toVqJbyjaQWuNQifluSuY7vgCU4TJlP0JWojATbCZKD23co7KYmqzOxRLLZS1wWHuBkODqXw4O3bNZRQ/ZE= X-Received: by 2002:a05:6808:150d:b0:437:f573:b175 with SMTP id 5614622812f47-45015efa004mr1572368b6e.31.1762527237034; Fri, 07 Nov 2025 06:53:57 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ron Johnson Date: Fri, 7 Nov 2025 09:53:45 -0500 X-Gm-Features: AWmQ_bnPq9H9VJVSY_spT1gdP3JESYaRFZ7n1uTJIhar9XAYo7yIP5q3h6MFFZI Message-ID: Subject: Re: Enquiry about long-running queries To: pgsql-general Content-Type: multipart/alternative; boundary="000000000000ded7410643025968" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ded7410643025968 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Nov 7, 2025 at 8:49=E2=80=AFAM Ashish Mukherjee wrote: > Hello, > > I have a query like this showing up on my production database - > > s05=3D> SELECT pid, user, usename, application_name, client_addr, > client_hostname, client_port, datname, now() - query_start as "runtime", > state, wait_event_type, wait_event, > substr(query, 0, 100) > FROM pg_stat_activity > WHERE now() - query_start > '5 minutes'::interval and state =3D 'active' > ORDER BY runtime DESC; > pid | user | usename | application_name | client_addr | > client_hostname | client_port | datname | runtime > | state | wait_event_type | wait_event | > substr > > -------+--------+-----------------+----------------+---------------------= ----------------------------------------------- > 356274 | s05 | s05 | scandir | 192.168.64.61 | > | 44098 | s05 | 9 days 18:45:37 > .65577 | active | IPC | ParallelFinish | select scac_code fro= m > scac where supported_by_smc =3D true > > The query when run from psql prompt finishes in a jiffy, so query > performance/cost is not the problem. Also, when I try to kill the query > through pg_terminate_backend or pg_cancel_backend, it does not get killed= . > If it runs in a jiffy, *do you have time* to kill it before it finishes? > I am wondering what could be the root cause of this problem and how it > could be addressed. Any pointers would be appreciated. > What problem? The query existing, or not being able to kill a query that finishes before you have time to kill it? --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --000000000000ded7410643025968 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Nov 7, 2025 at 8:49=E2=80=AFAM As= hish Mukherjee <ashish.muk= herjee@gmail.com> wrote:
Hello,

I have a query like this showing up on my prod= uction database -=C2=A0

s05=3D> SELECT pid, user,= usename, application_name, client_addr, client_hostname, client_port, datn= ame, now() - query_start as "runtime",
state, wait_event_type,= wait_event,
substr(query, 0, 100)
=C2=A0FROM =C2=A0pg_stat_activity<= br>=C2=A0WHERE now() - query_start > '5 minutes'::interval and s= tate =3D 'active'
=C2=A0ORDER BY runtime DESC;
=C2=A0 =C2=A0p= id =C2=A0 | user | usename | application_name | =C2=A0client_addr =C2=A0| c= lient_hostname | client_port | datname | =C2=A0 =C2=A0 =C2=A0 =C2=A0runtime=
=C2=A0 =C2=A0 =C2=A0 =C2=A0| state =C2=A0| wait_event_type | =C2=A0 wai= t_event =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 substr
-------+--------+----------------= -+----------------+--------------------------------------------------------= ------------
=C2=A0 356274 | s05 =C2=A0| s05 =C2=A0 =C2=A0 | scandir =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 192.168.64.61 | =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 44098 | s05 =C2=A0 = =C2=A0 | 9 days 18:45:37
.65577 | active | IPC =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 | ParallelFinish | select scac_code from scac where suppo= rted_by_smc =3D true

The query when run from psql = prompt finishes in a jiffy, so query performance/cost is not the problem. A= lso, when I try to kill the query through pg_terminate_backend or pg_cancel= _backend, it does not get killed.
If it runs in a jiffy, do you have time to kill it befo= re it finishes?
=C2=A0
I am wondering what could be the ro= ot cause of this problem and how it could be addressed.=C2=A0 Any pointers = would be appreciated.
<= br>
What problem?=C2=A0 The query existing, or not being able to = kill a query that finishes before you have time to kill it?

<= /div>--
Death to <Redacted>, and b= utter sauce.
Don't boil me, I'm still alive.
<R= edacted> lobster!
--000000000000ded7410643025968--