0

We just upgraded a Rails app to 4.2 to 5.2, everything is working like a charm in development, but when we try to release the app on our production servers, we can't run any rails related commands (assets precompilation, migrate, console, etc.).

Here is the trace:

Traceback (most recent call last):
    15: from bin/rails:4:in `<main>'
    14: from bin/rails:4:in `require'
    13: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
    12: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
    11: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
    10: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
     9: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
     8: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
     7: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/console/console_command.rb:95:in `perform'
     6: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
     5: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/command/actions.rb:28:in `require_environment!'
     4: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
     3: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:292:in `require'
     2: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
     1: from /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
     /var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require': failed to allocate memory (NoMemoryError)

We added puts file; just before the result = super in dependencies.rb:291, and a puts 'ERROR!' in the rescue in dependencies.rb#L260 and here are the last loaded files:

active_support/per_thread_registry
rack/runtime
rack/utils
active_support/cache/strategy/local_cache_middleware
rack/body_proxy
rack/utils
tzinfo/data
ERROR!
active_support/core_ext/time/zones
ERROR!
Traceback (most recent call last):

More information:

  • There is 52G of memory on the server, and we already tried adding 10G of SWAP.
  • Running htop is not giving any Memory leak

EDIT:

We tried removing the raise in dependencies.rb#L261 and of course the console loads, here are the logs:

rack/body_proxy
rack/utils
tzinfo/data
ERROR!
active_support/core_ext/time/zones
tzinfo/data/definitions/America/New_York
ERROR!
/var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/tzinfo-1.2.5/lib/tzinfo/ruby_data_source.rb:35: warning: constant ::Data is deprecated
/var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:396: warning: constant ::Data is deprecated
/var/deploy/slaask_kb/web_head/shared/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/inflector/methods.rb:283: warning: constant ::Data is deprecated
ERROR!
rails/console/app
active_support/all
action_controller
rails/console/helpers
active_record/base
pp
Loading production environment (Rails 5.2.3)
e2mmap
ERROR!
irb(main):001:0> 
Rémi Delhaye
  • 794
  • 3
  • 16
  • did you compare list of installed gems on production and on development? also check bundle version and rake to be sure that is the same version – Nezir Dec 05 '19 at 12:26
  • Are you sure Ruby 2.6 is compatible with Rails 5.2 ? This may be the issue.. what version of Ruby do you use locally ? – Maxence Dec 06 '19 at 01:26
  • @Maxence we're using 2.6.4p104 both in production and development – Rémi Delhaye Dec 06 '19 at 09:11
  • @RémiDelhaye I am not sure this is fully compatible : https://stackoverflow.com/questions/9087116/which-ruby-on-rails-is-compatible-with-which-ruby-version Try to revert to an older Ruby version if possible – Maxence Dec 06 '19 at 09:49

1 Answers1

1

I was able to reproduce the issue on a development environment (Windows Subsystem for Linux) too.

We finally managed to solve it by upgrading tzinfo from 1.1 to 1.2.5, as suggested here: https://github.com/tzinfo/tzinfo/issues/30