summaryrefslogtreecommitdiff
path: root/lib/gitlab/seeder.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
commit41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch)
tree9c8d89a8624828992f06d892cd2f43818ff5dcc8 /lib/gitlab/seeder.rb
parent0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff)
downloadgitlab-ce-41fe97390ceddf945f3d967b8fdb3de4c66b7dea.tar.gz
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'lib/gitlab/seeder.rb')
-rw-r--r--lib/gitlab/seeder.rb37
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/gitlab/seeder.rb b/lib/gitlab/seeder.rb
index 5671fce481f..e2df60c46f1 100644
--- a/lib/gitlab/seeder.rb
+++ b/lib/gitlab/seeder.rb
@@ -62,10 +62,6 @@ module Gitlab
end
def self.quiet
- # Disable database insertion logs so speed isn't limited by ability to print to console
- old_logger = ActiveRecord::Base.logger
- ActiveRecord::Base.logger = nil
-
# Additional seed logic for models.
Project.include(ProjectSeed)
User.include(UserSeed)
@@ -75,9 +71,11 @@ module Gitlab
SeedFu.quiet = true
- without_statement_timeout do
- without_new_note_notifications do
- yield
+ without_database_logging do
+ without_statement_timeout do
+ without_new_note_notifications do
+ yield
+ end
end
end
@@ -85,7 +83,6 @@ module Gitlab
ensure
SeedFu.quiet = false
ActionMailer::Base.perform_deliveries = old_perform_deliveries
- ActiveRecord::Base.logger = old_logger
end
def self.without_gitaly_timeout
@@ -112,10 +109,30 @@ module Gitlab
end
def self.without_statement_timeout
- ActiveRecord::Base.connection.execute('SET statement_timeout=0')
+ Gitlab::Database::EachDatabase.each_database_connection do |connection|
+ connection.execute('SET statement_timeout=0')
+ end
+ yield
+ ensure
+ Gitlab::Database::EachDatabase.each_database_connection do |connection|
+ connection.execute('RESET statement_timeout')
+ end
+ end
+
+ def self.without_database_logging
+ old_loggers = Gitlab::Database.database_base_models.transform_values do |model|
+ model.logger
+ end
+
+ Gitlab::Database.database_base_models.each do |_, model|
+ model.logger = nil
+ end
+
yield
ensure
- ActiveRecord::Base.connection.execute('RESET statement_timeout')
+ Gitlab::Database.database_base_models.each do |connection_name, model|
+ model.logger = old_loggers[connection_name]
+ end
end
end
end