weird long time query

Kaijiang Chen <[email protected]> Tue, 17 Dec 2019 10:58:17 +0800
Newsgroups gmane.comp.db.postgresql.performance
Message-ID <CAAkGvS8ocfeVFOCsxoAY6suzMkrW+O9twRAQ2c4WrZNbQ=vSpg@mail.gmail.com>
--000000000000a3bf9e0599dd8047
Content-Type: text/plain; charset="UTF-8"

I'm using postgres 9.4.17 on centos 7.
I check the running queries with the following SQL:
SELECT
    procpid,
    start,
    now() - start AS lap,
    current_query
FROM
    (SELECT
        backendid,
        pg_stat_get_backend_pid(S.backendid) AS procpid,
        pg_stat_get_backend_activity_start(S.backendid) AS start,
        pg_stat_get_backend_activity(S.backendid) AS current_query
    FROM
        (SELECT pg_stat_get_backend_idset() AS backendid) AS S
    ) AS S
WHERE
    current_query <> '<IDLE>'
ORDER BY
    lap DESC;

Then, I found a SQL that has run for some days (and still running):
procpid       | 32638
start         | 2019-11-25 16:29:29.529318+08
lap           | 21 days 18:24:54.707369
current_query | DEALLOCATE pdo_stmt_00000388

I tried to kill it with: SELECT pg_cancel_backend(32638) but it takes no
effects.

What's this query and what shall I do for it?

Best Wishes
Kaijiang

--000000000000a3bf9e0599dd8047
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I&#39;m using postgres=C2=A09.4.17 on centos 7.<div>I chec=
k the running queries with the following SQL:<div>SELECT <br>=C2=A0 =C2=A0 =
procpid, =C2=A0<br>=C2=A0 =C2=A0 start, =C2=A0<br>=C2=A0 =C2=A0 now() - sta=
rt AS lap, =C2=A0<br>=C2=A0 =C2=A0 current_query =C2=A0<br>FROM <br>=C2=A0 =
=C2=A0 (SELECT <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 backendid, =C2=A0<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 pg_stat_get_backend_pid(S.backendid) AS procpid, =C2=
=A0<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pg_stat_get_backend_activity_start(S.bac=
kendid) AS start, =C2=A0<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pg_stat_get_backend=
_activity(S.backendid) AS current_query =C2=A0<br>=C2=A0 =C2=A0 FROM <br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (SELECT pg_stat_get_backend_idset() AS backendi=
d) AS S =C2=A0<br>=C2=A0 =C2=A0 ) AS S =C2=A0<br>WHERE <br>=C2=A0 =C2=A0 cu=
rrent_query &lt;&gt; &#39;&lt;IDLE&gt;&#39; <br>ORDER BY <br>=C2=A0 =C2=A0 =
lap DESC;<br></div><div><br></div><div>Then, I found a SQL that has run for=
 some days (and still running):</div><div>procpid =C2=A0 =C2=A0 =C2=A0 | 32=
638<br>start =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 2019-11-25 16:29:29.529318+08<br=
>lap =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 21 days 18:24:54.707369<br>curren=
t_query | DEALLOCATE pdo_stmt_00000388<br></div><div><br></div><div>I tried=
 to kill it with:=C2=A0SELECT pg_cancel_backend(32638) but it takes no effe=
cts.</div><div><br></div><div>What&#39;s this query and what shall I do for=
 it?</div><div><br></div><div>Best Wishes</div><div>Kaijiang</div><div><br>=
</div></div></div>

--000000000000a3bf9e0599dd8047--