Re: DROP ROLE: how to detect active sessions?

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

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

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ken Lalonde 2010-10-21 18:46:45 Re: DROP ROLE: how to detect active sessions?
Previous Message Ken Lalonde 2010-10-21 18:04:11 DROP ROLE: how to detect active sessions?