2

When executing rake db:migrate command, it hangs on the Execute db:schema:dump step. I am using jruby 1.7.10 and the db gem jdbc-db2 v 9.7. It seems like the schema.rb file is successfully created in the db directory but the command still just hangs on that step.

Any thoughts on what could be causing this would be helpful.

ekremkaraca
  • 1,453
  • 2
  • 18
  • 37
user1103205
  • 175
  • 2
  • 13
  • have you checked state of your db? Had same problem with postgresql and db server reloading has solved it – MikeZ Mar 12 '14 at 15:14
  • i had the same issue (rake --trace db:migrate) showed me the hanging step. I found a fix here - just overriding rake task https://stackoverflow.com/questions/6453267/how-to-disable-dbschemadump-for-migrations – Florian Widtmann Feb 06 '19 at 15:12

1 Answers1

0

I just went through something similar where my rake tests kept getting slower. I am using Rails 2.0.2, Ruby 1.8.6, and Oracle 11.2.

The problem was that Oracle has a recycle bin, and that was filling up as the tables get dropped and recreated every time you run rake tests.

To keep the recycle bin from getting huge, I added a step to purge it after preparing the test database. Create a file lib/tasks/databases.rake with the following:

namespace :db do
  namespace :test do
    task :prepare do
      # The Oracle recycle bin fills up and slows down the test preparation.
      ActiveRecord::Base.connection.execute("purge recyclebin")
    end
  end
end

You probably don't want to do this in your production database, but you aren't running db:test:prepare against your production database, are you?

I found the problem by noticing this query running for a long time:

 SELECT lower(i.index_name) as index_name, i.uniqueness, lower(c.column_name) as column_name
 FROM user_indexes i, user_ind_columns c
 WHERE i.table_name = 'QCS_USERS'
 AND c.index_name = i.index_name
 AND i.index_name NOT IN (SELECT uc.index_name FROM user_constraints uc WHERE uc.constraint_type = 'P')
 ORDER BY i.index_name, c.column_position

Looking at the user_constraints table, I saw there were thousands of rows, even after I dropped all my tables, and that led me to some discussions of the recycle bin.

Community
  • 1
  • 1
Don Kirkby
  • 53,582
  • 27
  • 205
  • 286