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 1vHOP7-005riA-4t for pgsql-general@arkaria.postgresql.org; Fri, 07 Nov 2025 15:29:33 +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 1vHOP4-00F4fq-TR for pgsql-general@arkaria.postgresql.org; Fri, 07 Nov 2025 15:29:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vHOP4-00F4fh-Gh for pgsql-general@lists.postgresql.org; Fri, 07 Nov 2025 15:29:30 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vHOP2-006VtW-08 for pgsql-general@postgresql.org; Fri, 07 Nov 2025 15:29:29 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-b72cbc24637so144189466b.0 for ; Fri, 07 Nov 2025 07:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1762529367; x=1763134167; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=4WcwLCBHBegeL/xqxxwf0HoUUfXDdJPAqkXPX8M9B68=; b=jrjrj4JC8lQvSygYdCSk/CJGDGCDGTOxxIWwQduY8eKhwqJITMpaor8JhhAl4hBkAg L6X/K7T5aBvwKB/rHoj+u6GMPaijUU7gX/NFFv3gE/0/eDPTht4OREqaiCeRQuN6YP0F 2Z3A4gaJhmfdG+RtBP3OGII1WWX0b4DRd3bihmAW+nV8llZZOh1TQT0DG0haEl47N795 GfM0liwEW4RKRYacUe8/cjKh9vsWS/Aoa08wb/Am3yRrcBtV2dBaGMTDh08WpGA3RN2F FKA2xGljMymY3rpP2zUdgw0d3pYHrT69mYHx8Vo1Wce6532ON3IUfkJ/vv40Z/SY/cnq t68g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762529367; x=1763134167; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4WcwLCBHBegeL/xqxxwf0HoUUfXDdJPAqkXPX8M9B68=; b=NsqUhbMvB73Y55UFR3Qt0topDTaN4IoLJpg2Gl+nJKH7fYUR0Vj0Ljv6wey//ThSX6 +gfbTSYlvkAPo1rl9eewX/L76Pv7U2L77v/vw0UzOXYh86XGZoh9P6DCgMXSPF8p/0Cb f2SUIo7Y+FVwUdpQEf7z9pVJrzOGKURZsOQcW+wcxDfIDT7F1NMA4RMaiIg8mI53mNbN sjZvG12l5BmygEu88HksJQrIo4tbwaTwriHAVdPSMMrJSPgjORI8eh7Bat/UmLrIiqD5 ftLHHzfpp+INy1H+CXVaYaZB6k6Ih0bnjHw/a07yeKlq/0vBV8vJI6R6QeqdqYHRrjQ4 IQjg== X-Forwarded-Encrypted: i=1; AJvYcCXfOlZLoGA0VHFjV1MknRT8QmpryawKOuuHSQUVEKjVGSurDlDee7zc1dnWYESYgxMRhsZIZpPYlE7RR4G6@postgresql.org X-Gm-Message-State: AOJu0Yy91I7Jr5Gpz93rSf1z1vy7B9Jqrc1LsuVD8pZdB0SyPL0ufRZm clVLSny/4DU7p2IxP4VSXnLqmwVAnuUdeMSy5Rv6JelZZZ1geOszVcV3xP7Kc0JmoZA= X-Gm-Gg: ASbGnctXuNXWfCmWxUJ6vIEutsJroZzMh2CPYElbG2zlxl6REUJRmrZ/jpHPSquZPfq Xr6yuUkh5gCq50coJHBBvfTA5OAyEdwfASZ0wXsXmIqLtxEoWC3LnpYlRNdYAd5qTo7Tn9oqHFO 07LHcN2EBgnswCcRQslzg6J8YMuwSinwSlZwugFoxNV7jRLWFA3t2+PhNUfyxlNO4+cgnPGW1Dd dPHeW1qokBPxCAaT/NC3NLJm4JHnIsQSwehWwBAAdISGl/h6ciLVwKVsU/MWwkpwkpMG2PyMPfs io9SkoAPDMfvs6PV0AeuIcNY4nOEkvFYKhfvLbHDQL9ikWgWZ325FdM2NA1M/QlB3bfm9zC+4Ns Kz4w75yH2ioqhcoEm3oDM2X1UDrIAdUKOc3kszTZVgsedELLqylxO/6N34VgVlv9kqwWA0Mmelq WsgFB05fUMlKOTtp2pNwIdvdIS9o40FabX92MyJ1cI X-Google-Smtp-Source: AGHT+IE+hXqrwOySZkl+8RS40l/HmTJ3iTN264cVXj8pPg3Xw1qdd8vDzncmcQazTNiVLdKsWoLDWQ== X-Received: by 2002:a17:906:f59d:b0:b70:b161:b9be with SMTP id a640c23a62f3a-b72c078d7d0mr368555166b.20.1762529366506; Fri, 07 Nov 2025 07:29:26 -0800 (PST) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:682c:7fba:95a9:8d87:9526]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b72bfa24d1fsm261958766b.73.2025.11.07.07.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Nov 2025 07:29:26 -0800 (PST) Message-ID: <69982fc8a6ea2b7c2030d8206e16a8af081e7c46.camel@cybertec.at> Subject: Re: Enquiry about long-running queries From: Laurenz Albe To: Ashish Mukherjee , pgsql-general@postgresql.org Date: Fri, 07 Nov 2025 16:29:25 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2025-11-07 at 19:18 +0530, Ashish Mukherjee wrote: > I have a query like this showing up on my production database -=C2=A0 >=20 > 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) > =C2=A0FROM =C2=A0pg_stat_activity > =C2=A0WHERE now() - query_start > '5 minutes'::interval and state =3D 'ac= tive' > =C2=A0ORDER BY runtime DESC; > =C2=A0 =C2=A0pid =C2=A0 | user | usename | application_name | =C2=A0clien= t_addr =C2=A0| client_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 wait_= 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 | Paralle= lFinish | select scac_code from scac where supported_by_smc =3D true >=20 > The query when run from psql prompt finishes in a jiffy, so query perform= ance/cost is not the problem. > Also, when I try to kill the query through pg_terminate_backend or pg_can= cel_backend, it does not get killed. >=20 > I am wondering what could be the root cause of this problem and how it co= uld be addressed.=C2=A0 Any pointers would be appreciated. That is strange. The wait event means that the backend is waiting for para= llel workers to finish. But any existing parallel worker processes would also h= ave to show up in the query result. On what operating system does PostgreSQL run? What exact version is it? You could try to "strace" the backend process (or use an equivalent tool, i= f you are not on Linux) and see if the process issues any system calls. To see what's going on, you'd have to attach to the backend process with a debugger and take a stack trace. Yours, Laurenz Albe