pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PG_TERMINATE_BACKEND not working.
11+ messages / 8 participants
[nested] [flat]

* PG_TERMINATE_BACKEND not working.
@ 2012-11-16 06:34 Harry <shirlekar.harshal@gmail.com>
  2012-11-18 11:25 ` Re: PG_TERMINATE_BACKEND not working. Craig Ringer <craig@2ndQuadrant.com>
  2014-07-26 06:35 ` Re: PG_TERMINATE_BACKEND not working. byfei163@163.com <byfei163@163.com>
  0 siblings, 2 replies; 11+ messages in thread

From: Harry @ 2012-11-16 06:34 UTC (permalink / raw)
  To: pgsql-general

I am facing problem i.e. connections after execution completed are residing
in pg_stat_activity and pg_stat_database.
but when i am trying to kill them manually using pg_terminate_backend (All
IDLE connections are getting killed but, others like declare, select etc.)
are not getting killed getting result false.
Kindly help to resolve this issue.



--
View this message in context: http://postgresql.1045698.n5.nabble.com/PG-TERMINATE-BACKEND-not-working-tp5732379.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: PG_TERMINATE_BACKEND not working.
  2012-11-16 06:34 PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
@ 2012-11-18 11:25 ` Craig Ringer <craig@2ndQuadrant.com>
  2012-11-18 11:48   ` Re: PG_TERMINATE_BACKEND not working. Chris Angelico <rosuav@gmail.com>
  1 sibling, 1 reply; 11+ messages in thread

From: Craig Ringer @ 2012-11-18 11:25 UTC (permalink / raw)
  To: Harry <shirlekar.harshal@gmail.com>; +Cc: pgsql-general

On 11/16/2012 02:34 PM, Harry wrote:
> I am facing problem i.e. connections after execution completed are residing
> in pg_stat_activity and pg_stat_database.
> but when i am trying to kill them manually using pg_terminate_backend (All
> IDLE connections are getting killed but, others like declare, select etc.)
> are not getting killed getting result false.
> Kindly help to resolve this issue.

More detail is needed.

Pg version?

OS and version?

Exact command output?

What the queries that're not terminated are doing?

Why you're terminating them / what problem you're trying to solve?




-- 
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services





^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: PG_TERMINATE_BACKEND not working.
  2012-11-16 06:34 PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
  2012-11-18 11:25 ` Re: PG_TERMINATE_BACKEND not working. Craig Ringer <craig@2ndQuadrant.com>
@ 2012-11-18 11:48   ` Chris Angelico <rosuav@gmail.com>
  2012-11-19 05:22     ` Re: PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Chris Angelico @ 2012-11-18 11:48 UTC (permalink / raw)
  To: pgsql-general

On Sun, Nov 18, 2012 at 10:25 PM, Craig Ringer <craig@2ndquadrant.com> wrote:
> On 11/16/2012 02:34 PM, Harry wrote:
>> I am facing problem i.e. connections after execution completed are residing
>> in pg_stat_activity and pg_stat_database.
>> but when i am trying to kill them manually using pg_terminate_backend (All
>> IDLE connections are getting killed but, others like declare, select etc.)
>> are not getting killed getting result false.
>> Kindly help to resolve this issue.
>
> More detail is needed.
>
> Pg version?
>
> OS and version?
>
> Exact command output?
>
> What the queries that're not terminated are doing?
>
> Why you're terminating them / what problem you're trying to solve?

And: Are you logged in as superuser when you try to kill them, and if
not, are the other sessions from your own user?

ChrisA




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: PG_TERMINATE_BACKEND not working.
  2012-11-16 06:34 PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
  2012-11-18 11:25 ` Re: PG_TERMINATE_BACKEND not working. Craig Ringer <craig@2ndQuadrant.com>
  2012-11-18 11:48   ` Re: PG_TERMINATE_BACKEND not working. Chris Angelico <rosuav@gmail.com>
@ 2012-11-19 05:22     ` Harry <shirlekar.harshal@gmail.com>
  2012-11-20 07:21       ` Re: PG_TERMINATE_BACKEND not working. Raghavendra <raghavendra.rao@enterprisedb.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Harry @ 2012-11-19 05:22 UTC (permalink / raw)
  To: pgsql-general

Chris Yes, i am logging in as Super User also, other side same user's
connection(Superuser) i am trying to kill.



--
View this message in context: http://postgresql.1045698.n5.nabble.com/PG-TERMINATE-BACKEND-not-working-tp5732379p5732694.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: PG_TERMINATE_BACKEND not working.
  2012-11-16 06:34 PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
  2012-11-18 11:25 ` Re: PG_TERMINATE_BACKEND not working. Craig Ringer <craig@2ndQuadrant.com>
  2012-11-18 11:48   ` Re: PG_TERMINATE_BACKEND not working. Chris Angelico <rosuav@gmail.com>
  2012-11-19 05:22     ` Re: PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
@ 2012-11-20 07:21       ` Raghavendra <raghavendra.rao@enterprisedb.com>
  2012-11-20 13:45         ` Re: PG_TERMINATE_BACKEND not working. dinesh kumar <dineshkumar02@gmail.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Raghavendra @ 2012-11-20 07:21 UTC (permalink / raw)
  To: Harry <shirlekar.harshal@gmail.com>; +Cc: pgsql-general

n Mon, Nov 19, 2012 at 10:52 AM, Harry <shirlekar.harshal@gmail.com> wrote:

> Chris Yes, i am logging in as Super User also, other side same user's
> connection(Superuser) i am trying to kill.
>
>
Can you give a try, by picking the IP's of the processes which are not
getting killed from pg_stat_activity(client_addr column) and make REJECT
entries in pg_hba.conf file as below:

host   all   all  <client_addr IP>   reject

and reload the cluster using pg_ctl -D $PGDATA reload

Now try killing the process

pg_ctl kill TERM  <Process PID>

---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: PG_TERMINATE_BACKEND not working.
  2012-11-16 06:34 PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
  2012-11-18 11:25 ` Re: PG_TERMINATE_BACKEND not working. Craig Ringer <craig@2ndQuadrant.com>
  2012-11-18 11:48   ` Re: PG_TERMINATE_BACKEND not working. Chris Angelico <rosuav@gmail.com>
  2012-11-19 05:22     ` Re: PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
  2012-11-20 07:21       ` Re: PG_TERMINATE_BACKEND not working. Raghavendra <raghavendra.rao@enterprisedb.com>
@ 2012-11-20 13:45         ` dinesh kumar <dineshkumar02@gmail.com>
  0 siblings, 0 replies; 11+ messages in thread

From: dinesh kumar @ 2012-11-20 13:45 UTC (permalink / raw)
  To: Harry <shirlekar.harshal@gmail.com>; +Cc: pgsql-general

Hi Harry,

As you reported "pg_terminate_backend(pid)" returning "f" when executing.
Please confirm are u getting any error like below .

postgres=# select pg_terminate_backend(342033);
WARNING:  PID 342033 is not a PostgreSQL server process
 pg_terminate_backend
----------------------
 f
(1 row)

Not sure, what kind of error your are getting while executing it. So,
requesting you to share your postgresql version, command what you have
executed and it's result. However, pg_terminate_backend() is responsible to
send "SIGTERM"  to it's OS process. From there onwards, OS will take care
about the given process termination.

Can you give a try, by picking the IP's of the processes which are not
> getting killed from pg_stat_activity(client_addr column) and make REJECT
> entries in pg_hba.conf file as below:
>
> host   all   all  <client_addr IP>   reject
>
> and reload the cluster using pg_ctl -D $PGDATA reload
>
> Now try killing the process
>
> pg_ctl kill TERM  <Process PID>
>

I am not sure why we are rejecting the incoming connections here.

Regards,
Dinesh
manojadinesh.blogspot.com

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: PG_TERMINATE_BACKEND not working.
  2012-11-16 06:34 PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
@ 2014-07-26 06:35 ` byfei163@163.com <byfei163@163.com>
  1 sibling, 0 replies; 11+ messages in thread

From: byfei163@163.com @ 2014-07-26 06:35 UTC (permalink / raw)
  To: pgsql-general

Then same problem with you,and any idea?



--
View this message in context: http://postgresql.1045698.n5.nabble.com/PG-TERMINATE-BACKEND-not-working-tp5732379p5812909.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* pg_terminate_backend not working
@ 2019-09-24 11:14 bhargav kamineni <bhargavpostgres@gmail.com>
  2019-09-24 17:38 ` Re: pg_terminate_backend not working bhargav kamineni <bhargavpostgres@gmail.com>
  2019-09-24 18:35 ` Re: pg_terminate_backend not working Jerry Sievers <gsievers19@comcast.net>
  0 siblings, 2 replies; 11+ messages in thread

From: bhargav kamineni @ 2019-09-24 11:14 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org; +Cc: bhargav kamineni <bhargavpostgres@gmail.com>

Hi Team ,

We are observing long running process hung in active state on one of our db
from last two days with usename 'xyz', We have tried killing the respective
pid with pg_terminate_backned(pid), it's returning true but the quires are
not actually being terminated. Based on the client address and port number
from pg_stat_activity  we found the connection origin and killed that
connection initiation process from that host , even after that the
connections on db from   'xyz' are not getting terminated.

and these connections are not making network calls a self dblink connection
is being established in the query.

as a workaround we have disabled the connections initiation script for xyz
user and restarted the database  right after restart we observed the new
connections from xyz user to database which is not  expected because as we
have  already disables the connections initiation script.

select  pg_postmaster_start_time();
   pg_postmaster_start_time
------------------------------
 2019-09-24 06:44:07.41594+00

select usename,backend_start from pg_stat_activity where now()-xact_start >
'3 hours' and usename ='xyz';
     usename     |         backend_start

-----------------+----------------------------
 xyz | 2019-09-24 06:44:38.879047+00 |
 xyz | 2019-09-24 06:44:38.880501+00 |
 xyz | 2019-09-24 06:44:38.881326+00 |
 xyz | 2019-09-24 06:44:38.877561+00 |
 xyz | 2019-09-24 06:44:38.878336+00 |

what could be the possible reason for these connections and
pg_termiante_backend(pid) not working ?

Thanks,
Bhargav K

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: pg_terminate_backend not working
  2019-09-24 11:14 pg_terminate_backend not working bhargav kamineni <bhargavpostgres@gmail.com>
@ 2019-09-24 17:38 ` bhargav kamineni <bhargavpostgres@gmail.com>
  1 sibling, 0 replies; 11+ messages in thread

From: bhargav kamineni @ 2019-09-24 17:38 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Any thoughts on this ?

On Tue, 24 Sep 2019 at 16:44, bhargav kamineni <bhargavpostgres@gmail.com>
wrote:

> Hi Team ,
>
> We are observing long running process hung in active state on one of our
> db from last two days with usename 'xyz', We have tried killing the
> respective pid with pg_terminate_backned(pid), it's returning true but the
> quires are not actually being terminated. Based on the client address and
> port number from pg_stat_activity  we found the connection origin and
> killed that connection initiation process from that host , even after that
> the connections on db from   'xyz' are not getting terminated.
>
> and these connections are not making network calls a self dblink
> connection is being established in the query.
>
> as a workaround we have disabled the connections initiation script for xyz
> user and restarted the database  right after restart we observed the new
> connections from xyz user to database which is not  expected because as we
> have  already disables the connections initiation script.
>
> select  pg_postmaster_start_time();
>    pg_postmaster_start_time
> ------------------------------
>  2019-09-24 06:44:07.41594+00
>
> select usename,backend_start from pg_stat_activity where now()-xact_start
> > '3 hours' and usename ='xyz';
>      usename     |         backend_start
>
> -----------------+----------------------------
>  xyz | 2019-09-24 06:44:38.879047+00 |
>  xyz | 2019-09-24 06:44:38.880501+00 |
>  xyz | 2019-09-24 06:44:38.881326+00 |
>  xyz | 2019-09-24 06:44:38.877561+00 |
>  xyz | 2019-09-24 06:44:38.878336+00 |
>
> what could be the possible reason for these connections and
> pg_termiante_backend(pid) not working ?
>
> Thanks,
> Bhargav K
>
>
>

^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: pg_terminate_backend not working
  2019-09-24 11:14 pg_terminate_backend not working bhargav kamineni <bhargavpostgres@gmail.com>
@ 2019-09-24 18:35 ` Jerry Sievers <gsievers19@comcast.net>
  2019-09-24 19:28   ` Re: pg_terminate_backend not working bhargav kamineni <bhargavpostgres@gmail.com>
  1 sibling, 1 reply; 11+ messages in thread

From: Jerry Sievers @ 2019-09-24 18:35 UTC (permalink / raw)
  To: bhargav kamineni <bhargavpostgres@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

bhargav kamineni <bhargavpostgres@gmail.com> writes:

> Hi Team ,
>
> We are observing long running process hung in active state on one of
> our db from last two days with usename 'xyz', We have tried killing
> the respective pid with pg_terminate_backned(pid), it's returning
> true but the quires are not actually being terminated. Based on the
> client address and port number from pg_stat_activity  we found the
> connection origin and killed that connection initiation process from
> that host , even after that the connections on db from   'xyz' are
> not getting terminated.

Your client backend is most likely sitting in a blocked sys call such as
network send, etc.

Not sure though what is relaunching them after you say they were
disabled some{where,how}.

HTH

>
> and these connections are not making network calls a self dblink
> connection is being established in the query.
>
> as a workaround we have disabled the connections initiation script
> for xyz user and restarted the database  right after restart we
> observed the new connections from xyz user to database which is not 
> expected because as we have  already disables the connections
> initiation script.
>
> select  pg_postmaster_start_time();
>    pg_postmaster_start_time  
> ------------------------------
>  2019-09-24 06:44:07.41594+00
>
> select usename,backend_start from pg_stat_activity where now()
> -xact_start > '3 hours' and usename ='xyz';
>      usename     |         backend_start                            
>                    
> -----------------+----------------------------
>  xyz | 2019-09-24 06:44:38.879047+00 |
>  xyz | 2019-09-24 06:44:38.880501+00 |
>  xyz | 2019-09-24 06:44:38.881326+00 |
>  xyz | 2019-09-24 06:44:38.877561+00 |
>  xyz | 2019-09-24 06:44:38.878336+00 | 
>
> what could be the possible reason for these connections and
> pg_termiante_backend(pid) not working ?
>
> Thanks, 
> Bhargav K  
>
>
>
>

-- 
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@comcast.net





^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: pg_terminate_backend not working
  2019-09-24 11:14 pg_terminate_backend not working bhargav kamineni <bhargavpostgres@gmail.com>
  2019-09-24 18:35 ` Re: pg_terminate_backend not working Jerry Sievers <gsievers19@comcast.net>
@ 2019-09-24 19:28   ` bhargav kamineni <bhargavpostgres@gmail.com>
  0 siblings, 0 replies; 11+ messages in thread

From: bhargav kamineni @ 2019-09-24 19:28 UTC (permalink / raw)
  To: Jerry Sievers <gsievers19@comcast.net>; +Cc: pgsql-general@lists.postgresql.org

> Hi Team ,
>
> We are observing long running process hung in active state on one of
> our db from last two days with usename 'xyz', We have tried killing
> the respective pid with pg_terminate_backned(pid), it's returning
> true but the quires are not actually being terminated. Based on the
> client address and port number from pg_stat_activity  we found the
> connection origin and killed that connection initiation process from
> that host , even after that the connections on db from   'xyz' are
> not getting terminated.

>Your client backend is most likely sitting in a blocked sys call such as
network send, etc.

these queries are not doing network calls,they have loopback dblink
connection with in.
>Not sure though what is relaunching them after you say they were
disabled some{where,how}.

Is there any  workaround  to  terminate those stuck process apart from
restarting the database ?

On Wed, 25 Sep 2019 at 00:05, Jerry Sievers <gsievers19@comcast.net> wrote:

> bhargav kamineni <bhargavpostgres@gmail.com> writes:
>
> > Hi Team ,
> >
> > We are observing long running process hung in active state on one of
> > our db from last two days with usename 'xyz', We have tried killing
> > the respective pid with pg_terminate_backned(pid), it's returning
> > true but the quires are not actually being terminated. Based on the
> > client address and port number from pg_stat_activity  we found the
> > connection origin and killed that connection initiation process from
> > that host , even after that the connections on db from   'xyz' are
> > not getting terminated.
>
> Your client backend is most likely sitting in a blocked sys call such as
> network send, etc.
>
> Not sure though what is relaunching them after you say they were
> disabled some{where,how}.
>
> HTH
>
> >
> > and these connections are not making network calls a self dblink
> > connection is being established in the query.
> >
> > as a workaround we have disabled the connections initiation script
> > for xyz user and restarted the database  right after restart we
> > observed the new connections from xyz user to database which is not
> > expected because as we have  already disables the connections
> > initiation script.
> >
> > select  pg_postmaster_start_time();
> >    pg_postmaster_start_time
> > ------------------------------
> >  2019-09-24 06:44:07.41594+00
> >
> > select usename,backend_start from pg_stat_activity where now()
> > -xact_start > '3 hours' and usename ='xyz';
> >      usename     |         backend_start
> >
> > -----------------+----------------------------
> >  xyz | 2019-09-24 06:44:38.879047+00 |
> >  xyz | 2019-09-24 06:44:38.880501+00 |
> >  xyz | 2019-09-24 06:44:38.881326+00 |
> >  xyz | 2019-09-24 06:44:38.877561+00 |
> >  xyz | 2019-09-24 06:44:38.878336+00 |
> >
> > what could be the possible reason for these connections and
> > pg_termiante_backend(pid) not working ?
> >
> > Thanks,
> > Bhargav K
> >
> >
> >
> >
>
> --
> Jerry Sievers
> Postgres DBA/Development Consulting
> e: postgres.consulting@comcast.net
>

^ permalink  raw  reply  [nested|flat] 11+ messages in thread


end of thread, other threads:[~2019-09-24 19:28 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-11-16 06:34 PG_TERMINATE_BACKEND not working. Harry <shirlekar.harshal@gmail.com>
2012-11-18 11:25 ` Craig Ringer <craig@2ndQuadrant.com>
2012-11-18 11:48   ` Chris Angelico <rosuav@gmail.com>
2012-11-19 05:22     ` Harry <shirlekar.harshal@gmail.com>
2012-11-20 07:21       ` Raghavendra <raghavendra.rao@enterprisedb.com>
2012-11-20 13:45         ` dinesh kumar <dineshkumar02@gmail.com>
2014-07-26 06:35 ` byfei163@163.com <byfei163@163.com>
2019-09-24 11:14 pg_terminate_backend not working bhargav kamineni <bhargavpostgres@gmail.com>
2019-09-24 17:38 ` Re: pg_terminate_backend not working bhargav kamineni <bhargavpostgres@gmail.com>
2019-09-24 18:35 ` Re: pg_terminate_backend not working Jerry Sievers <gsievers19@comcast.net>
2019-09-24 19:28   ` Re: pg_terminate_backend not working bhargav kamineni <bhargavpostgres@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox