summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-08 10:33:01 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-08 10:33:01 +0000
commit6edb7e9bb152d919c215f35bd6cb7d52fd3d99be (patch)
treef12ef4b7953932f9b2b9c28313277bf636115bc8 /lib
parent305ea394efd2d5afe16234406dede486d9ca37af (diff)
downloadgitlab-ce-6edb7e9bb152d919c215f35bd6cb7d52fd3d99be.tar.gz
Add latest changes from gitlab-org/gitlab@14-4-stable-ee
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/fix_first_mentioned_in_commit_at.rb10
-rw-r--r--lib/gitlab/database/load_balancing/load_balancer.rb5
-rw-r--r--lib/gitlab/sidekiq_middleware/size_limiter/validator.rb12
3 files changed, 24 insertions, 3 deletions
diff --git a/lib/gitlab/background_migration/fix_first_mentioned_in_commit_at.rb b/lib/gitlab/background_migration/fix_first_mentioned_in_commit_at.rb
index 9b278efaedd..8f785476aa0 100644
--- a/lib/gitlab/background_migration/fix_first_mentioned_in_commit_at.rb
+++ b/lib/gitlab/background_migration/fix_first_mentioned_in_commit_at.rb
@@ -14,7 +14,15 @@ module Gitlab
self.table_name = 'issue_metrics'
def self.from_2020
- where('EXTRACT(YEAR FROM first_mentioned_in_commit_at) > 2019')
+ where(first_mentioned_in_commit_at_condition)
+ end
+
+ def self.first_mentioned_in_commit_at_condition
+ if columns_hash['first_mentioned_in_commit_at'].sql_type == 'timestamp without time zone'
+ 'EXTRACT(YEAR FROM first_mentioned_in_commit_at) > 2019'
+ else
+ "EXTRACT(YEAR FROM first_mentioned_in_commit_at at time zone 'UTC') > 2019"
+ end
end
end
# rubocop: enable Style/Documentation
diff --git a/lib/gitlab/database/load_balancing/load_balancer.rb b/lib/gitlab/database/load_balancing/load_balancer.rb
index cc9ca325337..2be7f0baa60 100644
--- a/lib/gitlab/database/load_balancing/load_balancer.rb
+++ b/lib/gitlab/database/load_balancing/load_balancer.rb
@@ -52,7 +52,10 @@ module Gitlab
connection = host.connection
return yield connection
rescue StandardError => error
- if serialization_failure?(error)
+ if primary_only?
+ # If we only have primary configured, retrying is pointless
+ raise error
+ elsif serialization_failure?(error)
# This error can occur when a query conflicts. See
# https://www.postgresql.org/docs/current/static/hot-standby.html#HOT-STANDBY-CONFLICT
# for more information.
diff --git a/lib/gitlab/sidekiq_middleware/size_limiter/validator.rb b/lib/gitlab/sidekiq_middleware/size_limiter/validator.rb
index a83522a489a..71316bbd243 100644
--- a/lib/gitlab/sidekiq_middleware/size_limiter/validator.rb
+++ b/lib/gitlab/sidekiq_middleware/size_limiter/validator.rb
@@ -28,15 +28,21 @@ module Gitlab
#
# The worker classes aren't constants here, because that would force
# Application Settings to be loaded earlier causing failures loading
- # the environmant in rake tasks
+ # the environment in rake tasks
EXEMPT_WORKER_NAMES = ["BackgroundMigrationWorker", "Database::BatchedBackgroundMigrationWorker"].to_set
+ JOB_STATUS_KEY = 'size_limiter'
class << self
def validate!(worker_class, job)
return if EXEMPT_WORKER_NAMES.include?(worker_class.to_s)
+ return if validated?(job)
new(worker_class, job).validate!
end
+
+ def validated?(job)
+ job.has_key?(JOB_STATUS_KEY)
+ end
end
DEFAULT_SIZE_LIMIT = 0
@@ -64,6 +70,8 @@ module Gitlab
end
def validate!
+ @job[JOB_STATUS_KEY] = 'validated'
+
job_args = compress_if_necessary(::Sidekiq.dump_json(@job['args']))
return if @size_limit == 0
@@ -72,8 +80,10 @@ module Gitlab
exception = exceed_limit_error(job_args)
if compress_mode?
+ @job.delete(JOB_STATUS_KEY)
raise exception
else
+ @job[JOB_STATUS_KEY] = 'tracked'
track(exception)
end
end