Skip to content

Kill all PostgreSQL connections for rake dev:setup

Stan Hu requested to merge sh-terminate-pg-connections-on-setup into master

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 terminates 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 gitlab-development-kit#450 (closed)

Edited by Stan Hu

Merge request reports