MCPcopy Create free account
hub / github.com/PostHog/duckgres / releaseFileDB

Method releaseFileDB

server/server.go:813–829  ·  view source on GitHub ↗

releaseFileDB decrements the ref count for a user's shared DB. When the last reference is released, the DB is closed and removed from the pool.

(username string)

Source from the content-addressed store, hash-verified

811// DrainUserConnections requests a clean close of every PostgreSQL connection
812// for one org user. It is used when a project reader's credentials or access
813// policy changes so an established connection cannot retain stale access.
814func (s *Server) DrainUserConnections(orgID, username string) int {
815 return s.drainConnections(func(c *clientConn) bool {
816 return c.orgID == orgID && c.username == username
817 })
818}
819
820func (s *Server) drainConnections(matches func(*clientConn) bool) int {
821 s.connsMu.RLock()
822 conns := make([]*clientConn, 0)
823 for _, c := range s.conns {
824 if c != nil && matches(c) {
825 conns = append(conns, c)
826 }
827 }
828 s.connsMu.RUnlock()
829
830 for _, c := range conns {
831 c.drainRequested.Store(true)
832 if c.conn != nil && c.idleRead.Load() {

Callers 3

safeCleanupDBMethod · 0.80
serveMethod · 0.80

Calls 1

CloseMethod · 0.65

Tested by 1