Issue with rake db:migrate – infinite loop?

Pablo Costa Public Seen by 33

Hi there folks!

Today I put some time aside to upgrade our Loomio instance and I am in the process of running rake db:migrate as per the README.md

The process is taking too long, and I'm afraid it's stuck in an infinite loop on [1]. The loop is writing the same ID over and over, with

puts parent_ids.last

I edited the migration file, improved and moved the "puts" call so it's the last line in the loop:

puts "parent_ids.last: #{parent_ids.last} count: #{count}"

and I can confirm that the counter is not changing, it's stuck at 538. I have a little over 11K rows in the "events" table.

I tried to understand what's going on but I failed to grasp the logic with the "500" and the rails idioms in the loop

while count > 500

I do have a backup, but I don't feel I have the knowledge to figure out the docker image versions and how to pin them in the docker-compose file in order to restore the original environment.

I'd really appreciate any insight on the logic of the migration so I'd have something to dig in the database and maybe figure out what's going on and how to properly address this in the migration.

Thanks for reading, anyway :)

[1] https://github.com/loomio/loomio/blob/master/db/migrate/20200801054702_update_all_discussion_items_with_position_key.rb


Rob Guthrie Sat 27 Feb

Hi @Pablo Costa - I'm just about to leave for a 3 day bush walk (in about 20 minutes!) .... that said, I've just altered that migration - removed the loop and changed it to create background jobs to update the threads, it it will happen quickly, then do the work in the background. So.. if you find that your threads don't work immediately after the upgrade, you might just need to give it time, and check out hostname/sidekiq as a user with is_admin = true to see the progress


Rob Guthrie Tue 2 Mar

@Pablo Costa did the changes I made work out for you? (you would need to change your docker-compose to use the :latest image rather than stable)


Pablo Costa Fri 5 Mar

Hey @Rob Guthrie , it worked at the moment, I was amazed for the quick fix in the 20 minutes before you leaving :) And I had all the migrations applied right away. Apologies for not responding properly, I just reacted to your reply, but that's not a fair reply, for sure :)


Rob Guthrie Tue 9 Mar

oh that's great news.