Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails, Passenger and Memcached: Unable to find server during initialization

I hope someone can help me with a problem that I am certain is a user error.

The configuration details below work in all my other environments including integration, development and qa. However, the production servers give the following error:

<ActionController::Session::MemCacheStore:0x2b45f6acb248> unable to find server during initialization.

When I telnet to the memcached box from the server having the problem and run 'stats', I get:

STAT pid 16136  
STAT uptime 7398638  
STAT time 1275059978    
STAT version 1.2.8    
STAT pointer_size 64  
STAT rusage_user 7.085922  
STAT rusage_system 13.275981  
STAT curr_items 10878  
STAT total_items 11441  
STAT bytes 2020180  
STAT curr_connections 5  
STAT total_connections 306  
STAT connection_structures 11  
STAT cmd_flush 0  
STAT cmd_get 457326  
STAT cmd_set 11441  
STAT get_hits 412184  
STAT get_misses 45142  
STAT evictions 0  
STAT bytes_read 22600329  
STAT bytes_written 53036649  
STAT limit_maxbytes 30064771072  
STAT threads 5  
STAT accepting_conns 1  
STAT listen_disabled_num 0

Below are the configuration details and stacktrace.

config/environment.rb (the important parts):

config.action_controller.session_store = :mem_cache_store  
config.gem "memcache-client", :lib => 'memcache'  

config/environments/production.rb:

config.cache_store = :mem_cache_store

require 'memcache'  

# Caching  
# Memcached configuration  
memcache_options = {  
  :c_threshold => 100_000,  
  :compression => true,  
  :debug => false,  
  :namespace => 'gucci',  
  :readonly => false,  
  :urlencode => false,  
  :multithread => true  
}  

CACHE = MemCache.new memcache_options  
CACHE.servers = ['10.x.x.x:11211']  

Stacktrace:

/var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/session/mem_cache_store.rb    20      in `initialize'  
1   /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb   72  in `new'  
2   /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb   72  in `build'  
3   /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb   116     in `build'  
4   /var/www/oro/production/releases/20100528130253/vendor/rails/activesupport/lib/active_support/inflector.rb  361     in `inject'  
5   /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb   116     in `each'  
6   /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb   116     in `inject'  
7   /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb   116     in `build'  
8   /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/dispatcher.rb     130     in `build_middleware_stack'  
9   /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/dispatcher.rb     81  in `initialize'  
10  /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/dispatcher.rb     51  in `new'  
11  /var/www/oro/production/releases/20100528130253/vendor/rails/actionpack/lib/action_controller/dispatcher.rb     51  in `run_prepare_callbacks'  
12  /var/www/oro/production/releases/20100528130253/vendor/rails/railties/lib/initializer.rb    631     in `prepare_dispatcher'  
13  /var/www/oro/production/releases/20100528130253/vendor/rails/railties/lib/initializer.rb    185     in `process'  
14  /var/www/oro/production/releases/20100528130253/vendor/rails/railties/lib/initializer.rb    113     in `send'  
15  /var/www/oro/production/releases/20100528130253/vendor/rails/railties/lib/initializer.rb    113     in `run'  
16  /var/www/oro/production/releases/20100528130253/config/environment.rb   29  
17  /usr/local//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   31  in `gem_original_require'  
18  /usr/local//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   31  in `require'
19  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/railz/application_spawner.rb   303     in `preload_application'  
20  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/railz/application_spawner.rb   252     in `initialize_server'  
21  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/utils.rb   255     in `report_app_init_status'  
22  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/railz/application_spawner.rb   237     in `initialize_server'  
23  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/abstract_server.rb     194     in `start_synchronously'  
24  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/abstract_server.rb     163     in `start'  
25  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/railz/application_spawner.rb   213     in `start'  
26  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/spawn_manager.rb   262     in `spawn_rails_application'  
27  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/abstract_server_collection.rb  126     in `lookup_or_add'  
28  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/spawn_manager.rb   256     in `spawn_rails_application'  
29  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/abstract_server_collection.rb  80  in `synchronize'  
30  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/abstract_server_collection.rb  79  in `synchronize'  
31  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/spawn_manager.rb   255     in `spawn_rails_application'  
32  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/spawn_manager.rb   154     in `spawn_application'  
33  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/spawn_manager.rb   287     in `handle_spawn_application'  
34  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/abstract_server.rb     352     in `__send__'  
35  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/abstract_server.rb     352     in `main_loop'  
36  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/lib/phusion_passenger/abstract_server.rb     196     in `start_synchronously'  
37  /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.10/bin/passenger-spawn-server   61
like image 580
Rodney Avatar asked May 28 '10 15:05

Rodney


2 Answers

For me it turned out, that my memcache daemon did not listen to 127.0.0.1 but to localhost. After removing the -l localhost option from the init file it worked perfectly. (Default is to listen on all devices.)

like image 180
CBuente Avatar answered Nov 19 '22 04:11

CBuente


I had some similar issues with the memcached gem and switched to dali. Development on dali seems more active and it is significantly faster. I followed the directions on the github page and had dali up and running in about ten minutes.

like image 1
Rourke Avatar answered Nov 19 '22 02:11

Rourke