method

cancel_any_running_query

cancel_any_running_query()
private

No documentation available.

# File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 127
          def cancel_any_running_query
            return if @raw_connection.nil? || IDLE_TRANSACTION_STATUSES.include?(@raw_connection.transaction_status)

            # Skip @raw_connection.cancel (PG::Connection#cancel) when using libpq >= 18 with pg < 1.6.0,
            # because the pg gem cannot obtain the backend_key in that case.
            # This method is only called from exec_rollback_db_transaction and exec_restart_db_transaction.
            # Even without cancel, rollback will still run. However, since any running
            # query must finish first, the rollback may take longer.
            if !(PG.library_version >= 18_00_00 && Gem::Version.new(PG::VERSION) < Gem::Version.new("1.6.0"))
              @raw_connection.cancel
            end
            @raw_connection.block
          rescue PG::Error
          end