MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / DropConnections

Method DropConnections

pkg/management/postgres/instance.go:1488–1504  ·  view source on GitHub ↗

DropConnections drops all the connections of backend_type 'client backend'

()

Source from the content-addressed store, hash-verified

1486
1487// DropConnections drops all the connections of backend_type 'client backend'
1488func (instance *Instance) DropConnections() error {
1489 conn, err := instance.GetSuperUserDB()
1490 if err != nil {
1491 return err
1492 }
1493
1494 if _, err := conn.Exec(
1495 `SELECT pg_catalog.pg_terminate_backend(pid)
1496 FROM pg_catalog.pg_stat_activity
1497 WHERE pid <> pg_backend_pid()
1498 AND backend_type = 'client backend';`,
1499 ); err != nil {
1500 return fmt.Errorf("while dropping connections: %w", err)
1501 }
1502
1503 return nil
1504}
1505
1506// GetPrimaryConnInfo returns the DSN to reach the primary
1507func (instance *Instance) GetPrimaryConnInfo() string {

Callers 1

reconcilePrimaryMethod · 0.80

Calls 2

GetSuperUserDBMethod · 0.95
ExecMethod · 0.80

Tested by

no test coverage detected