"Cannot allocate memory" when upgrading


(Prateek) #1

Hi,
I just got a message on my new discourse forum to upgrade to the latest version. On proceeding to the installation (on the black console), i saw some error messages that i dont really remember about an older version. The forum is still up, but when i again try to click “click here to upgrade”, it takes me to the www.website.com/admin/upgrade , which says everything is up to date, but www.website.com/admin still says there are upgrades available.

Whats going on?
Thanks


(Prateek) #2

…a little help here, somebody?


#3

I don’t think that’s alarming, a little cache issue or the server that needs a reboot.

Go into the console (or Putty), and enter this command shutdown -r now


(Stefano Costa) #4

I don’t think rebooting is a solution or a recommended action for any problem with Discourse, especially if there’s been a problem with an upgrade.

The sensible action here is to move to the Discourse directory cd /var/discourse and rebuild the app from the command line with /launcher rebuild app.


(Prateek) #5

This is from the console that i get when trying to update -

An error occurred while installing eventmachine (1.2.0.1), and Bundler cannot
continue.
Make sure that gem install eventmachine -v '1.2.0.1' succeeds before bundling.

Then i did a “apt-get install ruby” (as suggested by my system) - I don’t know why i had to install ruby at this point. Anyway, it went successful.

And then when i do -

gem install eventmachine -v ‘1.2.0.1’

I get error “Error installing eventmachine. Failed to build gem native extension”


(Sam Saffron) #6

Try

cd /var/discourse
git pull
./launcher rebuild app

(Prateek) #7

Tried, still getting errors… Following is the stuff copied from the command line that opens while updating from the admin panel.

*** Please be patient, next steps might take a while ***
********************************************************
$ bundle install --deployment --without test --without development
Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Using rake 10.5.0
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Installing mini_portile2 2.1.0
Installing pkg-config 1.1.7
Using rack 1.6.4
Using mime-types 2.99.1
Using arel 6.0.3
Using jmespath 1.1.3
Using babel-source 5.8.34
Using execjs 2.6.0
Using ember-source 1.12.2
Using byebug 8.2.1
Using certified 1.0.0
Using coderay 1.1.0
Using concurrent-ruby 1.0.2
Using connection_pool 2.2.0
Using crass 1.0.2
Using daemons 1.2.3
Using diff-lcs 1.2.5
Using thor 0.19.1
Using discourse_fastimage 2.0.0
Using docile 1.1.5
Using unf_ext 0.0.7.1
Using email_reply_trimmer 0.1.3
Installing eventmachine 1.2.0.1 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/eventmachine-1.2.0.1/ext
/usr/local/bin/ruby -r ./siteconf20160522-8243-1yibai4.rb extconf.rb
Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20160522-8243-1yibai4.rb extconf.rb 2>&1

Gem files will remain installed in /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/eventmachine-1.2.0.1 for inspection.
Results logged to /var/www/discourse/vendor/bundle/ruby/2.0.0/extensions/x86_64-linux/2.0.0-static/eventmachine-1.2.0.1/gem_make.out
Using excon 0.45.4
Using exifr 1.2.4
Using fabrication 2.9.8
Using fakeweb 1.3.0
Using multipart-post 2.0.0
Using fast_blank 1.0.0
Installing fast_stack 0.2.0 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/fast_stack-0.2.0/ext/fast_stack
/usr/local/bin/ruby -r ./siteconf20160522-8243-b66lhp.rb extconf.rb
Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20160522-8243-b66lhp.rb extconf.rb 2>&1

Gem files will remain installed in /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/fast_stack-0.2.0 for inspection.
Results logged to /var/www/discourse/vendor/bundle/ruby/2.0.0/extensions/x86_64-linux/2.0.0-static/fast_stack-0.2.0/gem_make.out
Using fast_xs 0.8.0
Using ffi 1.9.10
Using flamegraph 0.9.5
Using fspath 2.1.1
Using sorcerer 1.0.2
Using guess_html_encoding 0.0.11
Using hashie 3.4.3
Using highline 1.7.8
Using hiredis 0.6.1
Using htmlentities 4.3.4
Using http_accept_language 2.0.5
Using image_size 1.4.1
Using in_threads 1.3.1
Using progress 3.1.1
Using jwt 1.5.2
Using kgio 2.10.0
Using libv8 3.16.14.13
Using listen 0.7.3
Using logster 1.2.3
Using lru_redux 1.1.0
Using metaclass 0.0.4
Using method_source 0.8.2
Using mock_redis 0.15.4
Using moneta 0.8.0
Using msgpack 0.7.4
Using multi_json 1.11.2
Using multi_xml 0.5.5
Using mustache 1.0.3
Using netrc 0.11.0
Using oauth 0.4.7
Using oj 2.14.3
Using ruby-openid 2.7.0
Using redis 3.3.0
Using pg 0.18.4
Using slop 3.6.0
Using puma 3.2.0
Using r2 0.2.6
Using bundler 1.12.0
Using rails_multisite 1.0.4
Using raindrops 0.15.0
Using rb-fsevent 0.9.7
Using trollop 2.1.2
Using ref 2.0.0
Using rinku 1.7.3
Using rmmseg-cpp 0.2.9
Using rspec-support 3.2.2
Using rtlit 0.0.5
Using sass 3.2.19
Using tilt 2.0.2
Using shoulda-context 1.2.1
Using simple-rss 1.3.1
Using simplecov-html 0.10.0
Using spork 1.0.0rc4
Using timecop 0.8.0
Using rake-compiler 0.9.9
Using tzinfo 1.2.2
Installing nokogiri 1.6.8.rc3 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.8.rc3/ext/nokogiri
/usr/local/bin/ruby -r ./siteconf20160522-8243-7ly6nb.rb extconf.rb
Cannot allocate memory - /usr/local/bin/ruby -r ./siteconf20160522-8243-7ly6nb.rb extconf.rb 2>&1

Gem files will remain installed in /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.8.rc3 for inspection.
Results logged to /var/www/discourse/vendor/bundle/ruby/2.0.0/extensions/x86_64-linux/2.0.0-static/nokogiri-1.6.8.rc3/gem_make.out
Using rack-test 0.6.3
Using message_bus 2.0.0.beta.11
Installing rack-mini-profiler 0.10.1
Using rack-protection 1.5.3
Using mail 2.6.4
Using aws-sdk-core 2.2.9
Using babel-transpiler 0.7.0
Using uglifier 2.7.2
Using barber 0.11.1
Using ember-data-source 1.0.0.beta.16.1
Using sprockets 3.6.0
Using unf 0.1.4
An error occurred while installing eventmachine (1.2.0.1), and Bundler cannot
continue.
Make sure that `gem install eventmachine -v '1.2.0.1'` succeeds before bundling.

I tried “gem install bundler” as suggested by the logs, but that doesn’t work either.


(Steve Kemp) #8

It looks like this is your problem:

“Cannot allocate memory”

The solution here is to stop apache, stop mysql, stop all the services you can, temporarily, such that you have free RAM and can build the gems. Then post-build you can restart them.

Failing that if you’re on a virtual machine pay for more RAM.


(cpradio) #9

Or add a swap file or increase the size of your swap file.


(Steve Kemp) #10

Good point. I guess take a look at this recent discussion:


(Prateek) #11

i use a 2 GB RAM server…and i have almost 1 GB free… pretty sure that is free enough.
Any other ideas?


(Steve Kemp) #12

If you read the link above, then visit the swap-file page you’ll see this:

We recommend a 2GB swap file for Discourse, unless your server has 4GB or more of memory.

I think that means that you should add the swap file and/or upgrade your RAM.


(Prateek) #13

i see… i’ll check that now. Thanks


(Dave Higgins) #14

I had this exact issue - Discourse on DO with 2GB RAM and no swap worked fine, except for updating from the Discourse dashboard. So I would always rebuild the app via SSH instead.
Adding 1GB swap file fixed it for me; updating from the dashboard now works.


(Prateek) #15

Hi,
I have some basic questions about creating a swap file -

1.) since i run a 2GB ram server, what should be the size of the swap that i create, and why?
2.) How will creating a swap file affect my server? If i create a 1 GB swap, will 1 GB be reserved just for the system processes for Discourse?
3.) As the forum grows, will i need to increase the size of the swap? What will determine how much should it be increased? And will the method to increase the swap be the same?

Many thanks!


(Jeff Atwood) #16

Just 2gb swap file is needed, it will mostly be used only during upgrades. If you have 4gb or more ram you may not need the swapfile.


(Prateek) #17

sorry for the dumb queston, but will the swap file take 2 gb from the ram or from the storage drive?


(Jeff Atwood) #18

From the disk only, that is the purpose of swap.


(Prateek) #19

Done. Created a 2 GB swap file and the upgrade works like a charm.

Here is the process - Create a swapfile for your Linux server


(Prateek) #20

Just want to add in - making the swap takes an additional around 300 MB of RAM. My total RAM usage for a starting forum is like 1700 MB now.

Discourse does take a toll on the RAM, but i guess it’s worth it.