summaryrefslogtreecommitdiff
path: root/lib/tasks/gitlab/setup.rake
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /lib/tasks/gitlab/setup.rake
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
downloadgitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'lib/tasks/gitlab/setup.rake')
-rw-r--r--lib/tasks/gitlab/setup.rake22
1 files changed, 1 insertions, 21 deletions
diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake
index a5289476378..006dfad3a95 100644
--- a/lib/tasks/gitlab/setup.rake
+++ b/lib/tasks/gitlab/setup.rake
@@ -30,7 +30,7 @@ namespace :gitlab do
# In production, we might want to prevent ourselves from shooting
# ourselves in the foot, so let's only do this in a test or
# development environment.
- terminate_all_connections unless Rails.env.production?
+ Rake::Task["dev:terminate_all_connections"].invoke unless Rails.env.production?
Rake::Task["db:reset"].invoke
Rake::Task["db:seed_fu"].invoke
@@ -38,24 +38,4 @@ namespace :gitlab do
puts "Quitting...".color(:red)
exit 1
end
-
- # If there are any clients connected to the DB, PostgreSQL won't let
- # you drop the database. It's possible that Sidekiq, Puma, or
- # some other client will be hanging onto a connection, preventing
- # the DROP DATABASE from working. To workaround this problem, this
- # method terminates all the connections so that a subsequent DROP
- # will work.
- def self.terminate_all_connections
- cmd = <<~SQL
- SELECT pg_terminate_backend(pg_stat_activity.pid)
- FROM pg_stat_activity
- WHERE datname = current_database()
- AND pid <> pg_backend_pid();
- SQL
-
- Gitlab::Database::EachDatabase.each_database_connection do |connection|
- connection.execute(cmd)
- rescue ActiveRecord::NoDatabaseError
- end
- end
end