Reputation: 953
I have two Rails 3.2.13 apps on Justhost server.
Recently they updated Mysql to Mysql2, after that I got errors:
Ruby (Rack) application could not be started
And specific:
Error message:
(Mysql2::Error)
My setup:
bundle show mysql turns : /home3/ecotec11/rails_apps/ecotechno/vendor/bundle/ruby/1.9.3/gems/mysql2-0.3.16
In database.yml
production:
adapter: mysql2
encoding: utf8
reconnect: true
database: database_name
pool: 5
username: username
password: password
# socket: /tmp/mysql.sock
Gemfile:
gem 'mysql2'
Bassicaly when I contacted support they said they can't help me.
Full backtrace of error :
0 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/mysql2-0.3.16/lib/mysql2/client.rb 24 in `initialize_ext'
1 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/mysql2-0.3.16/lib/mysql2/client.rb 24 in `initialize'
2 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/mysql2_adapter.rb 16 in `new'
3 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/mysql2_adapter.rb 16 in `mysql2_connection'
4 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb 315 in `new_connection'
5 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb 325 in `checkout_new_connection'
6 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb 247 in `block (2 levels) in checkout'
7 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb 242 in `loop'
8 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb 242 in `block in checkout'
9 /usr/lib64/ruby/1.9.3/monitor.rb 211 in `mon_synchronize'
10 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb 239 in `checkout'
11 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb 102 in `block in connection'
12 /usr/lib64/ruby/1.9.3/monitor.rb 211 in `mon_synchronize'
13 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb 101 in `connection'
14 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb 410 in `retrieve_connection'
15 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb 171 in `retrieve_connection'
16 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb 145 in `connection'
17 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/model_schema.rb 310 in `clear_cache!'
18 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activerecord-3.2.16/lib/active_record/railtie.rb 103 in `block (2 levels) in '
19 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/callbacks.rb 418 in `_run__4470304995410275411__prepare__777669663684257344__callbacks'
20 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/callbacks.rb 405 in `__run_callback'
21 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/callbacks.rb 385 in `_run_prepare_callbacks'
22 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/activesupport-3.2.16/lib/active_support/callbacks.rb 81 in `run_callbacks'
23 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/actionpack-3.2.16/lib/action_dispatch/middleware/reloader.rb 74 in `prepare!'
24 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/actionpack-3.2.16/lib/action_dispatch/middleware/reloader.rb 48 in `prepare!'
25 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/application/finisher.rb 47 in `block in '
26 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb 30 in `instance_exec'
27 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb 30 in `run'
28 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb 55 in `block in run_initializers'
29 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb 54 in `each'
30 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/initializable.rb 54 in `run_initializers'
31 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/application.rb 136 in `initialize!'
32 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/railties-3.2.16/lib/rails/railtie/configurable.rb 30 in `method_missing'
33 /home3/ecotec11/rails_apps/technorent/config/environment.rb 10 in `'
34 config.ru 3 in `require'
35 config.ru 3 in `block in
'
36 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/rack-1.4.5/lib/rack/builder.rb 51 in `instance_eval'
37 /home3/ecotec11/rails_apps/technorent/vendor/bundle/ruby/1.9.3/gems/rack-1.4.5/lib/rack/builder.rb 51 in `initialize'
38 config.ru 1 in `new'
39 config.ru 1 in `
'
40 /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb 225 in `eval'
41 /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb 225 in `load_rack_app'
42 /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb 157 in `block in initialize_server'
43 /etc/httpd/modules/passenger/lib/phusion_passenger/utils.rb 563 in `report_app_init_status'
44 /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb 154 in `initialize_server'
45 /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb 204 in `start_synchronously'
46 /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb 180 in `start'
47 /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb 129 in `start'
48 /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 253 in `block (2 levels) in spawn_rack_application'
49 /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb 132 in `lookup_or_add'
50 /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 246 in `block in spawn_rack_application'
51 /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb 82 in `block in synchronize'
52 prelude> 10:in `synchronize'
53 /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb 79 in `synchronize'
54 /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 244 in `spawn_rack_application'
55 /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 137 in `spawn_application'
56 /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 275 in `handle_spawn_application'
57 /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb 357 in `server_main_loop'
58 /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb 206 in `start_synchronously'
59 /etc/httpd/modules/passenger/helper-scripts/passenger-spawn-server 99 in `
In application logs :
Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml
Connecting to database specified by database.yml
I checked databases are present. Users with passwords are valid.
I tested if console works. Yes it works.
rails console production
I was able to create new record and also update existing one!
This makes me think what is wrong then ? If just for webservice database is not working ?
So from where this problem comes ?
Any tip would be great. thanks
Upvotes: 1
Views: 507
Reputation: 1299
I solved this easily by reverting to mysql, and adding the port number 3306 to my database.yml *for the record my app is on shared hosting on Bluehost.
previous database.yml:
development:
adapter: mysql2
database: my_db
encoding: utf8
username: my_username
password: my_password
host: localhost
reconnect: true
current database.yml:
development:
adapter: mysql
database: my_db
encoding: utf8
username: my_username
password: my_password
host: 127.0.0.1
reconnect: true
socket: mysql
port: 3306
Upvotes: 2