Welcome to mirror list, hosted at ThFree Co, Russian Federation.

empty_query_ping.rb « postgresql_adapter « database « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 906312478ac5a8e3854fc144c4ede020bb015f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

# rubocop:disable Gitlab/ModuleWithInstanceVariables
module Gitlab
  module Database
    module PostgresqlAdapter
      module EmptyQueryPing
        # ActiveRecord uses `SELECT 1` to check if the connection is alive
        # We patch this here to use an empty query instead, which is a bit faster
        def active?
          @lock.synchronize do
            @connection.query ';'
          end
          true
        rescue PG::Error
          false
        end
      end
    end
  end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables