Module: PgReports::Modules::Connections

Extended by:
Connections
Included in:
Connections
Defined in:
lib/pg_reports/modules/connections.rb

Overview

Connection and lock analysis module Most report methods are generated from YAML definitions in lib/pg_reports/definitions/connections/

Instance Method Summary collapse

Instance Method Details

#cancel_query(pid) ⇒ Boolean

Cancel a specific query (softer than kill)

Parameters:

  • pid (Integer)

    Process ID to cancel

Returns:

  • (Boolean)

    Success status



29
30
31
32
# File 'lib/pg_reports/modules/connections.rb', line 29

def cancel_query(pid)
  result = executor.execute("SELECT pg_cancel_backend(:pid)", pid: pid)
  result.first&.fetch("pg_cancel_backend", false) || false
end

#kill_connection(pid) ⇒ Boolean

Kill a specific backend process

Parameters:

  • pid (Integer)

    Process ID to terminate

Returns:

  • (Boolean)

    Success status



21
22
23
24
# File 'lib/pg_reports/modules/connections.rb', line 21

def kill_connection(pid)
  result = executor.execute("SELECT pg_terminate_backend(:pid)", pid: pid)
  result.first&.fetch("pg_terminate_backend", false) || false
end