Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails crashes in production mode #1045

Closed
val99erie opened this issue Sep 30, 2016 · 6 comments
Closed

Rails crashes in production mode #1045

val99erie opened this issue Sep 30, 2016 · 6 comments
Labels

Comments

@val99erie
Copy link
Contributor

val99erie commented Sep 30, 2016

Descriptive summary

We have an app that uses curation_concerns. It seems to be working fine in development mode, but when we deploy the app to production, both the rails server and the rails console crash.

I tried running production mode on my laptop, and it did cause the rails console to crash. I was able to cause the error in development mode by setting config.eager_load = true in config/environments/development.rb.

I was able to reproduce the error in my curation_concerns workspace using the rails app that's generated by engine_cart.

I first saw the problem in CC v1.6.1 (we are in the middle of upgrading from v1.0.0), but I also saw it on master (as of today, commit fcaed70f)

Expected behavior

Rails console runs with no errors

Actual behavior

Rails console crashes

Steps to reproduce the behavior

Update: See comment below. Instead of toggling the eager_load in development mode, just run rails c in production mode instead.

  • bundle exec rake engine_cart:generate
  • cd .internal_test_app
  • bin/rails c
  • Notice that rails console runs with no errors
  • In config/environments/development.rb set config.eager_load = true
  • RAILS_ENV=production bin/rails c

Notice the error

@val99erie
Copy link
Contributor Author

val99erie commented Sep 30, 2016

Update: ignore this comment. This is a red herring caused by setting eager_load to true

Here are some more clues:

When running the debugger, I can see that /Users/valerie/.rvm/gems/ruby-2.3.1@cc/gems/hydra-access-controls-10.3.0/app/models/concerns/hydra/access_controls has already been loaded by the time that it tries to load Embargoable.

So I tried editing the app/models/concerns/hydra/access_controls.rb file in my installed hydra-access-controls-10.3.0 gem, and commenting out the line autoload :Embargoable.

But then I got a series of similar errors for loading other files. I tried commenting out all these lines from app/models/concerns/hydra/access_controls.rb:

#    autoload :WithAccessRight
#    autoload :Embargoable
#    autoload :Permissions

And this line from lib/hydra-access-controls.rb:

#  autoload :AdminPolicyBehavior

And then the rails console still crashes, but it crashes with a different error.

The new error is the exact error about trying to load a minter_state class that we saw in our production environment:
https://project-hydra.slack.com/files/acozine/F2HMD5M6H/minter_loaderror_stacktrace.txt

At this point, if I add this empty file to my workspace, the rails console will load without crashing:
.internal_test_app/app/models/minter_state.rb

(Note that you don't actually have to define the MinterState class in the file; the file just has to exist)

@val99erie val99erie added the bug label Sep 30, 2016
@val99erie
Copy link
Contributor Author

List of files that were already loaded at the time it tried to load Embargoable:
https://gist.github.com/val99erie/5eb8a94087c505632f8351e1b3c6ec44

@val99erie
Copy link
Contributor Author

val99erie commented Oct 18, 2016

Ok, ignore all those autoloading errors and just focus on the MinterState error message. Probably the class loading errors come from flipping the eager_load config without changing other configs to production mode.

If I run:

  • bundle exec rake engine_cart:generate
  • cd .internal_test_app
  • Edit config/secrets.rb to add a secret_key_base in the production section
  • RAILS_ENV=production bin/rails c

Then I can see the minter state error message.

@val99erie
Copy link
Contributor Author

I believe this is the parent bug:
samvera/noid-rails#29

@mjgiarlo
Copy link
Member

Addressed in #1061 (WIP).

@mjgiarlo
Copy link
Member

Fixed by #1061

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants