DropConnections drops all the connections of backend_type 'client backend'
()
| 1486 | |
| 1487 | // DropConnections drops all the connections of backend_type 'client backend' |
| 1488 | func (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 |
| 1507 | func (instance *Instance) GetPrimaryConnInfo() string { |
no test coverage detected