Module: Gitlab::Database::PostgresqlAdapter::EmptyQueryPing

Defined in:
lib/gitlab/database/postgresql_adapter/empty_query_ping.rb

Instance Method Summary collapse

Instance Method Details

#active?Boolean

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

Returns:

  • (Boolean)

13
14
15
16
17
18
19
20
# File 'lib/gitlab/database/postgresql_adapter/empty_query_ping.rb', line 13

def active?
  @lock.synchronize do
    @connection.query ';'
  end
  true
rescue PG::Error
  false
end