tokhi
tokhi

Reputation: 21616

rake db:migrate hangs in master environment

I try to execute rake db:migrate command but it hangs, I found similar posts but couldn't get any proper solution. I can execute this on the development environment without any problem but on master it hangs:

bundle exec bin/rake db:migrate   RAILS_ENV=master
==  AddPublishToPages: migrating ==============================================
-- add_column(:pages, :publish, :boolean)

I executed the command and waited around 60 minutes but I get nothing and this is what the log/master.log shows:

Migrating to AddPublishToPages (20150108140428)
   (0.3ms)  BEGIN

ruby,rails rake versions:

ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
--

bin/rake --version
rake, version 10.0.4
--

bin/rails --version
Rails 3.2.12

bundle -v
Bundler version 1.1.3

any idea?

Upvotes: 0

Views: 1059

Answers (1)

tokhi
tokhi

Reputation: 21616

problem resolved, the issue was that there were many lock sessions on that specific table thats why rake db:migrate was not able to gain access on that specific table. So executing the below query showed the number of lock sessions on the table:

SELECT *
  FROM pg_locks l
  JOIN pg_class t ON l.relation = t.oid AND t.relkind = 'r'
 WHERE t.relname = 'pages';

So I just restarted the postgresql server and the problem resolved.

Upvotes: 1

Related Questions