Broken default avatar links with no swap file


(Jonathan Lin) #1

I’m referring to the default avatar that comes on sign-up. They show as broken links. The images are pointed at something like /user_avatar/HOSTNAME/system/120/3.png

Anyone can help me out? I have S3 configured, no sure if that’s related.

<hash>
  <date type="dateTime">2015-01-16T09:52:22+00:00</date>
  <guid>db160488-4538-450f-a1c2-0703265dec54</guid>
  <user-id type="integer">1</user-id>
  <parameters>{"controller":"user_avatars","action":"show","hostname":"HOSTNAME","username":"system","size":"45","version":"3"}</parameters>
  <action>show</action>
  <controller>user_avatars</controller>
  <backtrace>[RAILS_ROOT]/app/models/optimized_image.rb:68:in `create_for'
[RAILS_ROOT]/app/controllers/user_avatars_controller.rb:95:in `get_optimized_image'
[RAILS_ROOT]/app/controllers/user_avatars_controller.rb:65:in `show_in_site'
[RAILS_ROOT]/app/controllers/user_avatars_controller.rb:40:in `block in show'
[RAILS_ROOT]/vendor/gems/rails_multisite/lib/rails_multisite/connection_management.rb:44:in `with_hostname'
[RAILS_ROOT]/app/controllers/user_avatars_controller.rb:39:in `show'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/abstract_controller/base.rb:189:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:113:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:113:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:149:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `block in halting'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:149:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:86:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:86:in `run_callbacks'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/abstract_controller/callbacks.rb:19:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/rescue.rb:29:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/notifications.rb:159:in `block in instrument'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/notifications.rb:159:in `instrument'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/abstract_controller/base.rb:136:in `process'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.8/lib/action_view/rendering.rb:30:in `process'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.2/lib/mini_profiler/profiling_methods.rb:79:in `block in profile_method'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal.rb:196:in `dispatch'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_controller/metal.rb:232:in `block in action'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:82:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:50:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/journey/router.rb:73:in `block in call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/journey/router.rb:59:in `each'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/journey/router.rb:59:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:678:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/builder.rb:59:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
[RAILS_ROOT]/lib/middleware/anonymous_cache.rb:119:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/flash.rb:254:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/message_bus-1.0.5/lib/message_bus/rack/middleware.rb:55:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/cookies.rb:560:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/query_cache.rb:36:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:82:in `run_callbacks'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/logster-0.1.6/lib/logster/middleware/reporter.rb:23:in `call'
[RAILS_ROOT]/config/initializers/silence_logger.rb:24:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/request_id.rb:21:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.2/lib/mini_profiler/profiler.rb:193:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:514:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application.rb:144:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/railtie.rb:194:in `public_send'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/railtie.rb:194:in `method_missing'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:65:in `block in call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `each'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `call'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:576:in `process_client'
[RAILS_ROOT]/lib/middleware/unicorn_oobgc.rb:95:in `process_client'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in `worker_loop'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `&lt;top (required)&gt;'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
[RAILS_ROOT]/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `&lt;main&gt;'</backtrace>
  <message>undefined method `close!' for nil:NilClass</message>
  <url>http://HOSTNAME/user_avatar/HOSTNAME/system/45/3.png</url>
  <exception-class>NoMethodError</exception-class>
</hash>

(Kane York) #2

Extracted the error from the trace.

Are you using a Docker install?


(Jonathan Lin) #3

Hi there,

Yes I have a Docker install. My install has two containers linked together: web and data.

Maybe it is related to another problem I am facing: Errno::ENOMEM: Cannot allocate memory when I try to upgrade discourse and discourse_manager. Thought I had swapfile on, but maybe I configured it wrong. Will report back if that fixes the problem.


(Kane York) #4

Yeah, that would cause it.

You need at least 2GB total memory to perform an upgrade (that’s ram + swap).


(Jonathan Lin) #5

Hi Kane,

Yes I did not have swap configured. I turned swap on, rebooted, but the broken avatar link issue remains.

The error came from discourse/optimized_image.rb at master · discourse/discourse · GitHub I think perhaps the app had problems writing the temp file to /tmp.

I entered my web container and found that /tmp is owned by a discourse user, but on the group level it was root. Could that be the problem? The following is a ls -al on my /tmp folder:

root@www:/var/www/discourse/tmp# ls -al
total 32
drwxr-xr-x 11 discourse root      4096 Jan 16 09:31 .
drwxr-xr-x 60 discourse discourse 4096 Jan 16 10:04 ..
-rw-r--r--  1 discourse root         0 Jan 11 14:55 .gitkeep
drwxr-xr-x  3 discourse www-data  4096 Jan 11 15:55 backups
drwxr-xr-x  3 discourse www-data  4096 Jan 16 09:31 cache
drwxrwxr-x  2 discourse discourse 4096 Jan 11 15:20 ember-rails
drwxrwxr-x  2 discourse discourse 4096 Jan 11 14:59 miniprofiler
drwxr-xr-x  2 discourse root      4096 Jan 16 11:07 pids
drwxr-xr-x  2 discourse root      4096 Jan 11 14:55 sockets

Thanks in advance!


(Jonathan Lin) #6

Looks like the problem went away now. Maybe it had to do with lack of memory after all…


(Jonathan Lin) #7

Hi guys, missing avatar problem is still around despite swap. It’s like now you see it now you don’t.

I have 2GB of swap on a 1GB RAM DO instance.

From the error log, seems like Image Magick is having trouble getting memory:

<message>Cannot allocate memory - convert -size 240x240 xc:'rgb(119,170,114)' -pointsize 200 -fill white -gravity Center -font 'Helvetica' -stroke 'rgb(95,136,91)' -strokewidth 2 -annotate -5+25 'M' 'public/uploads/letter_avatars/2/M/119_170_114/240.png'</message>

cat /proc/meminfo shows the following swap stats:

SwapTotal:       2097148 kB
SwapFree:         520844 kB

Any idea? Or is getting a bigger RAM inevitable?


(Kane York) #8
$ python -c 'used = 1024*1024*1024 + 520844 * 1024; print used, used*2, (2097148 - 520844)* 1024'
1607086080 3214172160 2147479552

Memory used:      1607086080
Memory available: 1614135296

That’s getting really, really tight in a fork() situation.

I’d say that you need to upgrade, because Ruby isn’t getting the vfork() enhancement soon.


(Jeff Atwood) #9

For the love of God can you guys please stop using source code highlighting on console output? So hard to read with random words colored random colors.

Indent 4 spaces or use ctrl+k to specify monospace, use backticks for source code only please (or add the word plaintext)


(Mittineague) #10

I’ve been looking for that myself. Trying ctrl+k

$ python -c 'used = 1024*1024*1024 + 520844 * 1024; print used, used*2, (2097148 - 520844)* 1024'
1607086080 3214172160 2147479552

Memory used:      1607086080
Memory available: 1614135296

Works a treat, Thanks! :smile: