diff options
author | Stan Hu <stanhu@gmail.com> | 2019-01-28 14:46:05 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-02-11 21:30:57 -0800 |
commit | 5488e8a4a3a2bb1493a58429d53e32c94f18114e (patch) | |
tree | d75871be74807056d0a0b206ad35cc5082f8f069 /lib/tasks/gitlab | |
parent | 91b88e0be4a943aa7000c7d921e77fc200c53500 (diff) | |
download | gitlab-ce-5488e8a4a3a2bb1493a58429d53e32c94f18114e.tar.gz |
Kill all PostgreSQL connections for rake dev:setup
If there are any clients connected to the DB, PostgreSQL won't let you
drop the database. It's possible that Sidekiq, Unicorn, or some other
client will be hanging onto a connection, preventing the DROP DATABASE
from working. To workaround this problem, this method cancels all the
connections so that the db:reset command will work.
Note that there's still a slight possibility a client connects after its
connection is terminated. If this is an issue, we could solve it by
revoking CONNECT access, but for now it seems this works.
Closes https://gitlab.com/gitlab-org/gitlab-development-kit/issues/450
Diffstat (limited to 'lib/tasks/gitlab')
-rw-r--r-- | lib/tasks/gitlab/setup.rake | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake index f71e69987cb..dab96c5c54d 100644 --- a/lib/tasks/gitlab/setup.rake +++ b/lib/tasks/gitlab/setup.rake @@ -25,6 +25,11 @@ namespace :gitlab do puts "" end + # 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. + Gitlab::Database.terminate_all_connections unless Rails.env.production? + Rake::Task["db:reset"].invoke Rake::Task["add_limits_mysql"].invoke Rake::Task["setup_postgresql"].invoke |