Sign up Sign in samples blog services contact support

error when migrating to 1.7

Support Ticket

answered

+issue

Hello! I just upgraded to Wagn 1.7. I pulled the latest version and everything worked good until I did "rake db:migrate RAILS_ENV=production", the migration process was terminated by an error:

 

 

- create rule for Admin User+*self, DELETE:  [ [Administrator] ]

- create rule for Another Admin User+*self, READ:  [ [Anyone Signed In] ]

-- execute("update cards set read_rule_id=903, read_rule_class='*self'  where trash is false and id=484")

   -> 0.0015s

rake aborted!

An error has occurred, all later migrations was canceled:

 

FAILURE creating Another Admin User+*self:

  #<NoMethodError: undefined method `card' for nil:NilClass>

./db/migrate//20110705033023_permissions_into_settings.rb:189:in `who_could'./db/migrate//20110705033023_permissions_into_settings.rb:103:in `up_without_benchmarks'./db/migrate//20110705033023_permissions_into_settings.rb:101:in `each'./db/migrate//20110705033023_permissions_into_settings.rb:(blablah...)

 

 

Is there anything that I have missed? Thank you in advance!

+discussion

Judging by that error, there appears to be some permissions data integrity issues associated with the "Another Admin User".  It appears that there is a permission assigned to a party that doesn't have a card. The log suggests that READ and DELETE are fine, so it must be either COMMENT or EDIT.

 

The good news is that integrity in the old permissions table shouldn't impact the new permissions system if we manage to get through the migration.

 

I would suggest that you edit db/migrate/20110705033023_permissions_into_settings.rb and change line 189 from

 

 

perm && [perm.party.card.key]

to

perm && perm.party && [perm.party.card.key]

This will make it so that the import skips over any party not associated with a card.

 

If you really want to investigate further to figure out what the intended permission was, you can open up a console (./script/console) and do something like this:

 

c = Card.fetch 'Another Admin User'

c.permissions

 

... and then look at the parties on those permissions to see if you can figure out why they're broken.


Thanks it skips that error. But there is another error while migrating:

 

- create rule for Contract Negotiation+*self, DELETE: [ [Anyone Signed In] ]

- create rule for Engagement Setup and Management+*self, EDIT: [ [Anyone Signed In] ]

rake aborted!

An error has occurred, all later migrations canceled:

 

FAILURE creating Engagement Setup and Management+*self:

#<Wagn::Exceptions::Oops: error saving Engagement Setup and Management+*self+*update: end of file reached, /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/net/protocol.rb:135:in `sysread'/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill'/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/timeout.rb:62:in `timeout'/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/timeout.rb:93 (blablah...)

 

Why did I encounter so many errors? Is it because I did not follow some rules while creating these cards? Thank you!

  --evanyw.....Thu Sep 01 10:20:34 -0700 2011


whoa, that's a weird error. Looks like it timed out for some reason. Do you have some sort of limit set? If you re-run the migration, does it fail at the same place?

 

I don't know how the data integrity issue got there -- could have something to do with deleting a user or role? Good news is that 1.7.0 drastically reduces the amount of permissions data and stops using the permissions table altogether, so I would expect to see fewer issues in the future.

  --Ethan McCutchen.....Thu Sep 01 10:37:18 -0700 2011


...also, this is by far the most involved migration in wagn's history. I hope we don't have to do anything of this magnitude again for a loooooong time !!!

  --Ethan McCutchen.....Thu Sep 01 10:38:12 -0700 2011


I've been working on the migration staff for almost 2 hours... The same error happens but not at the same place. It seems the timeout just happens at random place while doing "create rule" for cards. I just repeat this staff "migrate -> error occurs -> restore the database -> migrate..." Hope I can get through this...

  --evanyw.....Thu Sep 01 12:27:10 -0700 2011


can you paste a little more of the error message here?

 

+error

  - create rule for Software Architecture Planning+*self, DELETE:  [ [Anyone Signed In] ] rake aborted! An error has occurred, all later migrations canceled:   ...

 

maybe that will tell us what is setting the timeout limit. I think if we can just raise it we'll be fine.

 

The other option would be to break this into multiple migrations; definitely more work.

 

For what it's worth, you probably don't have to restore the database every time; usually migrations roll back transactions when they fail. You can confirm this by counting the cards before and after the run.

 

select count(*) from cards.

  --Ethan McCutchen.....Thu Sep 01 12:37:31 -0700 2011


Thanks! I have posted all the error messages from the console.

I tried to migrate without restoring after an error occured but it raised another error that terminated the migration...

  --evanyw.....Thu Sep 01 12:45:36 -0700 2011


wow, this is a huge pain!

 

OK, it looks like that new error has to do with notifications. We should turn them off for the migration. Try changing line 4 of modules/notification.rb to this:

 

return false if Card.record_userstamps==false || ENV['MIGRATE_PERMISSIONS'] == 'true'

  --Ethan McCutchen.....Thu Sep 01 12:53:07 -0700 2011


actually, if your mail server is acting up, that could explain the timeout issue, too.

  --Ethan McCutchen.....Thu Sep 01 12:53:49 -0700 2011


There are actually 2 types of error. One is the "error saving ...", and the other is the one I just updated (timeout issue).

  --evanyw.....Thu Sep 01 12:58:07 -0700 2011


OK. That works and now I am facing the last problem (I hope :D ) I've tried 4 times and the following error happens every time.

 

+error1

successfully updated read rules for 295 cards ==  GenerateReadRules: migrated (18.8646s) ====================================   ==  PermissionSettingsDetails: migrating ====================================== rake aborted! An error has occurred, all ...

  --evanyw.....Thu Sep 01 13:05:34 -0700 2011


Nice! The main part of the migration completed successfully. There are 4 more minor migrations, each of them DRAMATICALLY simpler.

 

This error is, again, a notifications issue. What mailer are you using? I'm now wondering if it started shooting you down because wagn was sending out so many notifications with the migrations. I'm guessing you're "watching" lots of cards on the site?

 

If you could switch your configuration to a dummy mailer for now it might fix the migration. But I'm guessing you'll need to get the mailer working again at some point, no?

  --Ethan McCutchen.....Thu Sep 01 13:34:30 -0700 2011


I just use ActionMailer. I registered an account from Gmail and use that mail to sent out all the notifications. I guess the problem is Wagn send so many emails using that gmail account in a short period that google disabled that account?

  --evanyw.....Thu Sep 01 14:27:13 -0700 2011


Ahhh! I just tried to log into that account and send testing email. Gmail said: You have reached a limit for sending mail... Too baad. I understand the cause of the problem and will switch another email account. I really appreciate your timely help! Thank you!

  --evanyw.....Thu Sep 01 14:32:07 -0700 2011


Oh, good! Sorry about the email limit; I had intended to turn that off in the migration before. We should probably find a way to turn it off automatically for all migrations.

 

-e

  --Ethan McCutchen.....Thu Sep 01 14:36:48 -0700 2011