X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AE0D153544 for ; Thu, 12 May 2005 12:07:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55441-09 for ; Thu, 12 May 2005 15:06:56 +0000 (GMT) Received: from koolancexeon.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by svr1.postgresql.org (Postfix) with ESMTP id C413753E11 for ; Thu, 12 May 2005 12:06:51 -0300 (ADT) Received: mail.g2switchworks.com 10.10.1.8 from 10.10.1.37 10.10.1.37 via HTTP with MS-WebStorage 6.5.6944 Received: from state.g2switchworks.com by mail.g2switchworks.com; 12 May 2005 10:06:49 -0500 Subject: Re: how do i kill user sessions? From: Scott Marlowe To: Chris Browne Cc: pgsql-admin@postgresql.org In-Reply-To: <60ekcdtm28.fsf@dba2.int.libertyrms.com> References: <00bc01c55665$31117340$1400a8c0@tgusta2> <1115843183.3868.237.camel@state.g2switchworks.com> <60ekcdtm28.fsf@dba2.int.libertyrms.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1115910409.3868.248.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 12 May 2005 10:06:49 -0500 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/146 X-Sequence-Number: 17575 On Wed, 2005-05-11 at 17:49, Chris Browne wrote: > smarlowe@g2switchworks.com (Scott Marlowe) writes: > > > On Wed, 2005-05-11 at 15:08, Ing. Jhon Carrillo wrote: > >> I have a problem with the users administration. When I want to erase > >> (drop) some databases there's an error: ** database "name_db" is being > >> accessed by other users.** I want to kill the user sessions conected > >> but i don't know how to do it (Kill the user sessions). > > > > First, use ps to find the pid of the offending users. for instance: > > > > ps ax|grep postgres|grep test > > 18925 pts/1 S 0:00 postgres: postgres test [local] idle > > > > then, as the postgres superuser, kill the backend: > > > > kill 18925 > > You may want to be careful about what signal you submit. > > If you do "kill -9", for instance, that may be a more severe > "thwacking" of the system than you intended. > > Hitting it with "kill -2" is usually the right answer; that's SIGINT. > > Other signals may cause the database to kill ALL the backends. > "kill -3", for instance... > > "kill -9" will terminate the whole database system, 'with extreme > prejudice,' which will be quite likely to turn out badly :-(. Not exactly. kill -9 on a single backend will not kill the whole database but WILL cause all backends to terminate and the database server to restart, which is rather severe. Also note that postgresql is designed to survive a kill -9 on all signals with aplomb, but a production system is definitely not the place to be testing it, eh? :) Also note that while most signal numbers are the same, it's a good idea to use the text name assigned, as they are always pretty much the same across different systems. Without specifying a specific signal, a TERM should be sent, which is a 15 on both Solaris and Linux and (I think) BSD. So, 'kill -s sigterm pidhere' is pretty much the same as 'kill pidhere'.