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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-20 12:40:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-20 12:40:42 +0300
commitee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch)
treef8479f94a28f66654c6a4f6fb99bad6b4e86a40e /lib/gitlab/query_limiting
parent62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff)
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'lib/gitlab/query_limiting')
-rw-r--r--lib/gitlab/query_limiting/transaction.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/gitlab/query_limiting/transaction.rb b/lib/gitlab/query_limiting/transaction.rb
index 2e31849caaa..46c0a0ddf7a 100644
--- a/lib/gitlab/query_limiting/transaction.rb
+++ b/lib/gitlab/query_limiting/transaction.rb
@@ -14,8 +14,13 @@ module Gitlab
# The maximum number of SQL queries that can be executed in a request. For
# the sake of keeping things simple we hardcode this value here, it's not
# supposed to be changed very often anyway.
- THRESHOLD = 100
- LOG_THRESHOLD = THRESHOLD * 1.5
+ def self.threshold
+ 100
+ end
+
+ def self.log_threshold
+ threshold * 1.5
+ end
# Error that is raised whenever exceeding the maximum number of queries.
ThresholdExceededError = Class.new(StandardError)
@@ -76,7 +81,7 @@ module Gitlab
end
def executed_sql(sql)
- return if @count > LOG_THRESHOLD || ignorable?(sql)
+ return if @count > self.class.log_threshold || ignorable?(sql)
@sql_executed << sql
end
@@ -86,15 +91,15 @@ module Gitlab
end
def threshold_exceeded?
- count > THRESHOLD
+ count > self.class.threshold
end
def error_message
header = 'Too many SQL queries were executed'
header = "#{header} in #{action}" if action
- msg = "a maximum of #{THRESHOLD} is allowed but #{count} SQL queries were executed"
+ msg = "a maximum of #{self.class.threshold} is allowed but #{count} SQL queries were executed"
log = @sql_executed.each_with_index.map { |sql, i| "#{i}: #{sql}" }.join("\n").presence
- ellipsis = '...' if @count > LOG_THRESHOLD
+ ellipsis = '...' if @count > self.class.log_threshold
["#{header}: #{msg}", log, ellipsis].compact.join("\n")
end
@@ -105,3 +110,5 @@ module Gitlab
end
end
end
+
+Gitlab::QueryLimiting::Transaction.prepend_mod