Giter Site home page Giter Site logo

Comments (6)

smurthys avatar smurthys commented on June 15, 2024

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.

wildtayne avatar wildtayne commented on June 15, 2024

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.

smurthys avatar smurthys commented on June 15, 2024

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.

wildtayne avatar wildtayne commented on June 15, 2024

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.

wildtayne avatar wildtayne commented on June 15, 2024

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.

wildtayne avatar wildtayne commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.