Comments (6)
I agree a function killConnections(userName)
is required. BTW, is there a way to get the pid(s)
for a user?
It is also necessary to understand when/why a connection may remain open.
from classdb.
the pid(s) for a user can be found in pg_stat_activity
, ie. from the query above,
SELECT pid
FROM pg_stat_activity
WHERE usename ='<username>';
That query also calls pg_terminate_backend
for all connections belonging to one user.
from classdb.
Because pg_terminate_backend
and related admin operations could be granted to users, we should grant that access to Instructor and DBManager roles.
Also, we could benefit from functions listConnections(userName)
and killConnection(pid)
granted to Instructor and DBManager. Please recommend the attributes included in the table listConnections
returns.
from classdb.
listConnections(userName)
should at a minimum return usename
(not typo) and pid
from pg_stat_activity
. It may also be helpful to return application_name
and client_addr
to get an idea of what computers and applications are causing the connections. There are also several timestamps in pg_stat_activity
: backend_start
, xact_start
, query_start
, and state_change
. I will try and better understand what these timestamps represent to decide which should be included.
Should we directly grant permissions on pg_terminate_backend
and similar to instructor and dbManager, or just provide them with the functions we create?
from classdb.
Based on the pg_stat_activity
docs, I think the two most useful timestamps are backend_start
and query_start
, which are the start time of the connection and start time of the last query respectively.
from classdb.
An initial version of listConnections(username)
, killUserConnections(username)
, and killConnection(pid)
have been added in 1391d3d. There are some permissions considerations with these functions, which are being discussed in #27. There is also an additional issue with pg_stat_activity
permissions I will create a new issue for.
from classdb.
Related Issues (20)
- Add session id to table DDLActivity (N) HOT 2
- Test scripts are not organized as components (M) HOT 1
- SET SESSION AUTHORIZATION breaks ClassDB.getSessionID() (W) HOT 1
- Not all object types are listed by listOwnedObjects (M)
- Automate removal of superuser-owned objects (N)
- Permit users to create schemas (N)
- Server-version comparison functions are too long to be part of another script (E)
- Unit tests for shared ownership of team objects are insufficient (M)
- Guard uses of ADD COLUMN IF NOT EXISTS; changed in pg9.6 (N)
- The documentation for function ClassDB.importConnectionLog is incomplete (M)
- Server version comparison uses incorrect preset option (W) HOT 1
- DDL activity logging inserts a duplicate entry for some ALTER TABLE statments (WE)
- Server-version comparers are not marked immutable (M) HOT 1
- Guard uses of DROP OWNED: changed in pg9.5 (N) HOT 1
- Incorrect script filename used for server initialization (W)
- Dropping a user as student from a DB removes the user from student role in all DBs on the server HOT 6
- Users known in one ClassDB database are able to log in to all ClassDB databases on the same server (W) HOT 1
- Parameter initialPwd in function createRole is probably unnecessary (E)
- Roles with login are not granted login privilege HOT 2
- Connection log import fails on Postgres 13 (W) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from classdb.