From: Ken Lalonde <kenl@gap.ca>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-admin@postgresql.org
Subject: Re: DROP ROLE: how to detect active sessions?
Date: Thu, 21 Oct 2010 14:46:45 -0400
Message-ID: <EA1730F5-4334-4C7A-B5D7-45ED9E00FFC4@gap.ca> (raw)
In-Reply-To: <27773.1287685132@sss.pgh.pa.us>
References: <61A975CD-61CC-40CF-87CA-46BEEC1CEEAF@gap.ca>
<27773.1287685132@sss.pgh.pa.us>
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@gap.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: kenl@gap.ca, tgl@sss.pgh.pa.us
Subject: Re: DROP ROLE: how to detect active sessions?
In-Reply-To: <EA1730F5-4334-4C7A-B5D7-45ED9E00FFC4@gap.ca>
References: <61A975CD-61CC-40CF-87CA-46BEEC1CEEAF@gap.ca> <27773.1287685132@sss.pgh.pa.us> <EA1730F5-4334-4C7A-B5D7-45ED9E00FFC4@gap.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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