Re: I can't cancel/terminate query.

From: Melvin Davidson <melvin6925(at)gmail(dot)com>
To: Edmundo Robles <edmundo(at)sw-argos(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: I can't cancel/terminate query.
Date: 2017-07-13 16:10:20
Message-ID: CANu8FiyH_+Uu09G2ZcC2FaE+52nh3fB5fy7DiY0-nbKdvtEbUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 13, 2017 at 11:57 AM, Edmundo Robles <edmundo(at)sw-argos(dot)com>
wrote:

> Hi! i have many too long time queries, the oldest is almost 16 days,
> so i tried to cancel and terminate with pg_cancel_backend and
> pg_terminate_backend but queries is still running.
>
> STIME ELAPSED ELAPSED %CPU PID COMMAND
> jun27 15-23:05:46 1379146 0.3 29660 postgres: argos_admin bdkairos
> 127.0.0.1(55605) SELECT
> jun27 15-23:05:46 1379146 0.3 29659 postgres: argos_admin bdkairos
> 127.0.0.1(55604) SELECT
> jun27 15-23:05:46 1379146 0.3 29658 postgres: argos_admin bdkairos
> 127.0.0.1(55603) SELECT
> jun27 15-23:05:16 1379116 0.3 29909 postgres: argos_admin bdkairos
> 127.0.0.1(55767) SELECT
> jun27 15-23:04:51 1379091 0.3 30097 postgres: argos_admin bdkairos
> 127.0.0.1(55909) SELECT
> jun27 15-23:03:49 1379029 0.3 30661 postgres: argos_admin bdkairos
> 127.0.0.1(56303) SELECT
> ...
> What should i do to safely close that queries, before to use kill
> command in linux?
>
> I have Postgres 9.4 running on debian jessie.
>
>
>
> --
>
>
T

*o cancel a process with pg_terminate_backend, you need to be a superuser.*
*So first;*

*SET ROLE postgres;*

Then you should be able to
*SELECT **pg_terminate_backend(<pid>); * Where <pid> is the pid of process
you want to termnate.
--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jerry Sievers 2017-07-13 17:21:50 Re: I can't cancel/terminate query.
Previous Message Zhu, Joshua 2017-07-13 16:09:22 Re: BDR node removal and rejoin