DROP ROLE: how to detect active sessions?

Поиск
Список
Период
Сортировка
От Ken Lalonde
Тема DROP ROLE: how to detect active sessions?
Дата
Msg-id 61A975CD-61CC-40CF-87CA-46BEEC1CEEAF@gap.ca
обсуждение исходный текст
Ответы Re: DROP ROLE: how to detect active sessions?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-admin
I need to track db activity by role.   All web-related connections to the db use the same user name.
When a user logs in via the web, the application code runs:
    SET ROLE "n"
where n is the ID value for the user in the "users" table.
(These numeric roles are created dynamically as needed).
We can then use the value of "current_user" to track activity.

So far so good.

The problem happens when we periodically drop roles for inactive users.
If I run DROP ROLE "n", and there happens to be an active session for that role,
we have a problem: in that session, "select current_user" fails with "invalid role OID: nnnn".

Is there any way to determine if a given role has any active sessions?

Thanks a bunch,

Ken Lalonde
Gap Adventures, Toronto

В списке pgsql-admin по дате отправления:

Предыдущее
От: Kieren Scott
Дата:
Сообщение: Re: Restricting schema sizes
Следующее
От: Tom Lane
Дата:
Сообщение: Re: DROP ROLE: how to detect active sessions?