Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajHal-0005B1-9e for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Mar 2016 02:35:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ajHak-0003IM-SK for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Mar 2016 02:35:14 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ajHZP-0001l8-Ho for pgsql-hackers@postgresql.org; Fri, 25 Mar 2016 02:33:51 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajHZM-0005dK-E8 for pgsql-hackers@postgresql.org; Fri, 25 Mar 2016 02:33:50 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 4A2E75F799; Thu, 24 Mar 2016 22:33:47 -0400 (EDT) Date: Thu, 24 Mar 2016 22:33:47 -0400 From: Stephen Frost To: Tom Lane Cc: Robert Haas , Kyotaro HORIGUCHI , Oskari Saarenmaa , "pgsql-hackers@postgresql.org" Subject: Re: Show dropped users' backends in pg_stat_activity Message-ID: <20160325023347.GZ3127@tamriel.snowman.net> References: <56E87CD8.60007@ohmu.fi> <16068.1458143290@sss.pgh.pa.us> <20160323.123541.203539504.horiguchi.kyotaro@lab.ntt.co.jp> <3577.1458835419@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="66JA64BHvaVFYarG" Content-Disposition: inline In-Reply-To: <3577.1458835419@sss.pgh.pa.us> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-77-generic (x86_64) X-Uptime: 22:30:58 up 30 days, 23:23, 8 users, load average: 0.00, 0.04, 0.09 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --66JA64BHvaVFYarG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tom Lane (tgl@sss.pgh.pa.us) wrote: > Robert Haas writes: > > I am not really in favor of half-fixing this. If we can't > > conveniently wait until a dropped role is completely out of the > > system, then I don't see a lot of point in trying to do it in the > > limited cases where we can. If LEFT JOIN is the way to go, then, > > blech, but, so be it. >=20 > I concur. Let's put the left join(s) into those views and call it > good. I'd suggest we also add some notes to the documentation that the correct approach to dropping users is to disallow access first, then kill any existing backends, and then drop the user. That, plus the left joins, seems like it's good enough. > BTW, I think we would need the left joins even if we had interlocking > in DROP, just to protect ourselves against race conditions. Remember > that what pg_stat_activity shows is a snapshot, which might be more or > less out of date compared to the catalog contents. True, though that would likely be a much smaller set of cases that might also be short lived. Might be good to also note in the docs how to kill off sessions which are regular users but which no longer have a username, for folks who end up in this situation that they managed to drop a role which still had connections to the system. Thanks! Stephen --66JA64BHvaVFYarG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJW9KOKAAoJEO1sijiDR2RViZ0QAKHvxtjG2Ja8qVnJc6QCpShP sXfpLBckR2g0ro1jbrGuUICFZZ7X+msEyNTmvDuMGOW92tIyLmAXbvwROpXd01IT XoJeImoBl5lVd9KZ5qhhaLE8GhhGv03rJAivfcX313U1cydsm6xe7CDatMrQkv35 PqINSHZNTyCS2w+eNZ/r3nkxTr1hCgooLi1cIoclAsBS15tE2+0UcDu2Fx4TXASt 8oKO3VhQnnvt24Bu2vrfC1jDnonD4PvxwzrYXUmVMCkUZyniJ5/yMXckvABlQWXB KEYEILRa95DorL+9o5jy+RQZts2KF27KFq07SfWs9DUFXCTcSRz1NhiyIp6zHRnM Wo0/zvXCROKS+M2wYF4kSKVtinFPVSgZi+JSjeEPg2PZBYV5ojZ88PiF0aBjd0L0 CfeSeCVgU9ZTRzaZEBUAPmHTSkiNQU9J664JJhsiXYfuk30VFdYU3+lbEXd/sddV wQYUDGTuD6672cYkuyUtocIj0P9ZCPOv+Y5xx+J0120WIQX9PNocNeuD7ifQFVn9 u0eHqGiORoj5TSfjTEM/azFXypLqC9mIckCkHAaj2XvwM+BxMcQ3OkQXdCtls/3e Pod6r2pjMXk++eH0UVJIKWRsOp9dtfsMJB3vTI3u788sF3JOYn4BKKq2Rv0RAs2L QW3VftFsqh1JhTl7b5TD =Rx8b -----END PGP SIGNATURE----- --66JA64BHvaVFYarG--