Re: DROP ROLE: how to detect active sessions?

From: Ken Lalonde <kenl(at)gap(dot)ca>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: DROP ROLE: how to detect active sessions?
Date: 2010-10-21 18:46:45
Message-ID: EA1730F5-4334-4C7A-B5D7-45ED9E00FFC4@gap.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

This is a web app, so the username is unknown until the user actually logs in.
It would be ideal if pg_stat_activity contained the current role.
Until then, I'll go with your second recommendation.

Thanks for such a quick and useful reply.

Ken

On 2010-10-21, at 2:18 PM, Tom Lane wrote:

> Ken Lalonde <kenl(at)gap(dot)ca> writes:
>> Is there any way to determine if a given role has any active sessions?
>
> Not if you're using SET ROLE. pg_stat_activity will show you the
> login role names for active sessions. Do you really need SET ROLE
> rather than logging in with the appropriate username?
>
> There are going to be race conditions in any case, of course.
> Probably the best solution is to just not try to drop roles
> except when the system is idle.
>
> regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Nick 2010-10-21 21:14:25 autovacuum launcher process eating up 17G+ of ram?
Previous Message Tom Lane 2010-10-21 18:18:52 Re: DROP ROLE: how to detect active sessions?