0

I was doing some testing on my app locally and ran into a database deadlock situation. After some googling on what do do about it i decided since it was just dev i'd blow away the database and recreate it.

Only this won't work. I've recreated the database a few times and I've never had any problems.

I can run a db:drop ok and db:create works but when I run db:migrate it just hangs.

I've restarted incase a process had some sort of lock on the db but no change.

No errors and when I do --trace I'm none the wiser.

Any help would be appreciated, even where to start to debug the problem

This is what I have for the database config...

development: adapter: sqlite3 database: db/dev.sqlite3 pool: 5 timeout: 5000

test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000

Thanks

3
  • Have you tried just using a puts in the first migration to see if it even gets there? Commented Sep 13, 2012 at 20:59
  • I just added puts "first migration" after the def self.up in the first migration an it doesn't appear when I run db:migrate. Also when I run rails s the webrick server also hangs, it shows the first few lines but never gets to the lines where it tells you the pid and port. I created a new rails app using the same gemset and i can do migrations and start the webrick server ok. Commented Sep 13, 2012 at 21:18
  • Sounds like it might have something to do with some custom stuff you've put in either the environment.rb file, the application.rb file or an initializer. Commented Sep 13, 2012 at 21:29

1 Answer 1

0

I'm not 100% on whether I should be saying this is answered but it's fixed. Thanks for your help weexpectedTHIS, I started looking at environment.rb, application.rb and boot.rb. I'd not put much in there. I saw in Environment.rb there was the line my_app::Application.initialize!.

I'm assuming this was where it was freezing up. I commented out this and sure enough the webrick would load, I could at least run rake db:migrate even though it failed and I could also get into the rails console. Obviously without the line I commented out the app didn't work at all. So I fired up the console with different things commented out, eventually all that was commented out was the my_app::Application.initialize! line.

I entered that line in the rails console and it hung, i cancelled and tried it a few more times and bang it just ran ok after a couple of goes. No idea why. I came across someone else who had a similar problem but his just miraculously started working for no apparent reason. Unfortunately I'm in the same boat, and not much help to anyone who experiences this in the future.

There was definitely something wrong with the app initializing but what exactly I don't know.

This link takes you through the initialization process in rails in detail so if someone is having similar issues perhaps have a read to get ideas.

http://guides.rubyonrails.org/initialization.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.