2019-06-14 21:22:26 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Git
|
|
|
|
module RuggedImpl
|
|
|
|
module UseRugged
|
|
|
|
def use_rugged?(repo, feature_key)
|
2020-05-29 14:08:26 -04:00
|
|
|
return Feature.enabled?(feature_key) if Feature.persisted_name?(feature_key)
|
2019-06-14 21:22:26 -04:00
|
|
|
|
2020-01-10 10:07:47 -05:00
|
|
|
# Disable Rugged auto-detect(can_use_disk?) when Puma threads>1
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab/issues/119326
|
|
|
|
return false if running_puma_with_multiple_threads?
|
|
|
|
|
2019-06-14 21:22:26 -04:00
|
|
|
Gitlab::GitalyClient.can_use_disk?(repo.storage)
|
|
|
|
end
|
2019-07-10 17:36:49 -04:00
|
|
|
|
2019-07-21 01:34:46 -04:00
|
|
|
def execute_rugged_call(method_name, *args)
|
2019-07-10 17:36:49 -04:00
|
|
|
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
|
2019-07-17 19:34:27 -04:00
|
|
|
start = Gitlab::Metrics::System.monotonic_time
|
|
|
|
|
2019-07-21 01:34:46 -04:00
|
|
|
result = send(method_name, *args) # rubocop:disable GitlabSecurity/PublicSend
|
2019-07-17 19:34:27 -04:00
|
|
|
|
|
|
|
duration = Gitlab::Metrics::System.monotonic_time - start
|
|
|
|
|
|
|
|
if Gitlab::RuggedInstrumentation.active?
|
|
|
|
Gitlab::RuggedInstrumentation.increment_query_count
|
2020-05-20 20:08:06 -04:00
|
|
|
Gitlab::RuggedInstrumentation.add_query_time(duration)
|
2019-07-21 01:34:46 -04:00
|
|
|
|
|
|
|
Gitlab::RuggedInstrumentation.add_call_details(
|
|
|
|
feature: method_name,
|
|
|
|
args: args,
|
|
|
|
duration: duration,
|
2019-12-27 10:08:16 -05:00
|
|
|
backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller))
|
2019-07-17 19:34:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
result
|
2019-07-10 17:36:49 -04:00
|
|
|
end
|
|
|
|
end
|
2020-02-24 22:08:49 -05:00
|
|
|
|
|
|
|
def running_puma_with_multiple_threads?
|
|
|
|
return false unless Gitlab::Runtime.puma?
|
|
|
|
|
|
|
|
::Puma.respond_to?(:cli_config) && ::Puma.cli_config.options[:max_threads] > 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def rugged_feature_keys
|
|
|
|
Gitlab::Git::RuggedImpl::Repository::FEATURE_FLAGS
|
|
|
|
end
|
|
|
|
|
|
|
|
def rugged_enabled_through_feature_flag?
|
|
|
|
rugged_feature_keys.any? do |feature_key|
|
|
|
|
Feature.enabled?(feature_key)
|
|
|
|
end
|
|
|
|
end
|
2019-06-14 21:22:26 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|