delayed_job daemon killed with error "Lost connection to MySQL server." - mysql

I have an application with the delayed jobs daemonized.
This daemonized delayed jobs process is being killed often.
But, when I invoke rake jobs:work manually, the corresponding delayedjob process doesn't get killed.
I am experiencing two scenarios with this issue:
The first scenario has the error listed in the log file
ImportSQLJob failed with ActiveRecord::StatementInvalid: Mysql2::Error: Lost connection to MySQL server during query: DELETE FROM `delayed_jobs` WHERE (`delayed_jobs`.`id` = 93528940) - 0 failed attempts
And delayed_job has been locked by the system.
The pid created exists in the applications "/tmp/pids/" folder but upon the checking the system process using ps -aux, couldn't find the process mentioned.
In the second scenario, the daemonized delayed_jobs process was killed without any errors in the log file, but here the jobs are not being locked and couldn't find the pids in the application's /tmp/pids/ directory. This is same as the one mentioned in the Google Groups thread. In that thread, Andrew Havens mentioned, regarding a patch for the daemons gem, that the srand() function was causing the issue. I couldn't find the patch made by him as the Rubyforge website is down permanently.
Upon checking the other posts in Stack Overflow, I suspect the issue to be either with the daemons gem or the mysql2 gem, but couldn't come to a conclusion because of my limited Rails knowledge.
And earlier I had a MySQL server go away issue and I added reconnect: true to my database.yml file which fixed that issue.
My production environment is:
OS: Ubuntu 12.04 LTS
Ruby version:1.9.3-p429
The gems which I use for my application are:
actionmailer (3.2.2)
actionpack (3.2.2)
activemodel (3.2.2)
activerecord (3.2.2)
activeresource (3.2.2)
activesupport (3.2.2)
arel (3.0.2)
builder (3.0.4)
bundler (1.3.5)
bundler-unload (1.0.1)
choice (0.1.6)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.4.0)
composite_primary_keys (5.0.8)
country-select (1.1.1)
daemon_controller (1.1.0)
daemons (1.1.9)
delayed_job (3.0.4)
delayed_job_active_record (0.3.3)
erubis (2.7.0)
eventmachine (1.0.0)
execjs (1.4.0)
faraday (0.8.4)
fastthread (1.0.7)
google-spreadsheet-ruby (0.3.0)
google_drive (0.3.2)
hike (1.2.1)
httpauth (0.2.0)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.3)
jquery-ui-rails (4.1.2)
json (1.7.5)
jwt (0.1.5)
libv8 (3.11.8.13 x86-linux)
log4r (1.1.10)
mail (2.4.4)
mime-types (1.19)
multi_json (1.3.7)
multipart-post (1.1.5)
mysql2 (0.3.11)
net-scp (1.2.1)
net-ssh (2.9.0)
nokogiri (1.5.5)
oauth (0.4.7)
oauth2 (0.8.0)
passenger (3.0.18)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.2)
rails (3.2.2)
railties (3.2.2)
rake (10.0.4, 10.0.1)
rdoc (3.12)
ref (1.0.2)
roo (1.10.1)
ruby-ole (1.2.11.5)
rubygems-bundler (1.2.0)
rubyzip (0.9.9)
rvm (1.11.3.8)
sass (3.2.3)
sass-rails (3.2.5)
spreadsheet (0.7.4)
sprockets (2.1.3)
therubyracer (0.11.4)
thin (1.5.0)
thor (0.14.6)
tilt (1.3.3)
todonotes (0.1.0)
treetop (1.4.12)
tzinfo (0.3.35)
uglifier (1.3.0)
will_paginate (3.0.3)
xml-simple (1.1.2)
And the database.yml file is:
production:
adapter: mysql2
encoding: utf8
database: smt_production
pool: 5
username: ****
password: ****
reconnect: true

Related

Gem::LoadError: Add `gem 'mysql'` to your Gemfile

Gem::LoadError: Specified 'mysql' for database adapter, but the gem is not loaded. Add `gem 'mysql'` to your Gemfile.
I have been getting this error when I was following this guide:
http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html
and running
$ cd activerecord
$ bundle exec rake test_sqlite3
After searching around for a bit, I've been told I need to modify the Gemfile and add gem 'mysql' then run bundle install. However, I am not able to see mysql in the list.
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.5)
Using json (1.8.0)
Using minitest (5.0.8)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.1.0.beta) from source at .
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.1.0.beta) from source at .
Using builder (3.1.4)
Using activemodel (4.1.0.beta) from source at .
Using erubis (2.7.0)
Using actionview (4.1.0.beta) from source at .
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.1.0.beta) from source at .
Using arel (4.0.0)
Using activerecord (4.1.0.beta) from source at .
Using bcrypt-ruby (3.1.2)
Using benchmark-ips (1.2.0)
Using bundler (1.3.5)
Using coffee-script-source (1.6.3)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.1.0.beta) from source at .
Using coffee-rails (4.0.0)
Using columnize (0.3.6)
Using dalli (2.6.4)
Using debugger-linecache (1.2.0)
Using debugger-ruby_core_source (1.2.3)
Using debugger (1.6.2)
Using hike (1.2.3)
Using jquery-rails (2.2.2)
Using mustache (0.99.4)
Using mini_portile (0.5.1)
Using nokogiri (1.6.0)
Using kindlerb (0.1.1)
Using metaclass (0.0.1)
Using mocha (0.14.0)
Using multi_json (1.8.1)
Using racc (1.4.9)
Using rack-cache (1.2)
Using tilt (1.4.1)
Using sprockets (2.10.0)
Using sprockets-rails (2.0.0)
Using rails (4.1.0.beta) from source at .
Using rdoc (3.12.2)
Using redcarpet (2.2.2)
Using sdoc (0.3.20)
Using sqlite3 (1.3.8)
Using turbolinks (1.3.0)
Using uglifier (2.2.1)
Using w3c_validators (1.2)
Using yajl-ruby (1.1.0)
Your bundle is complete!
Gems in the group db were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Gemfile
source 'https://rubygems.org'
gem 'rails', path: '/home/terence/rails'
gem 'arel', github: 'rails/arel'
gem 'mysql', '~> 2.9.1'
gem 'mysql2', '~> 0.3.13'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use edge version of sprockets-rails
gem 'sprockets-rails', github: 'rails/sprockets-rails'
# Use SCSS for stylesheets
gem 'sass-rails', github: 'rails/sass-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', github: 'rails/coffee-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
# Run `rails console` in the browser. Read more: https://github.com/rails/web-console
gem 'web-console', group: :development
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
But, if I run gem list, my output is the following:
*** LOCAL GEMS ***
actionmailer (4.0.0)
actionpack (4.0.0)
activemodel (4.0.0)
activerecord (4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.0)
arel (4.0.0)
atomic (1.1.14)
bcrypt-ruby (3.1.2)
benchmark-ips (1.2.0)
builder (3.1.4)
bundler (1.3.5)
bundler-unload (1.0.2)
celluloid (0.15.2)
chunky_png (1.2.8)
coderay (1.0.9)
coffee-rails (4.0.0)
coffee-script (2.2.0)
coffee-script-source (1.6.3)
columnize (0.3.6)
compass (0.12.2)
cyaml (0.0.45)
dalli (2.6.4)
debugger (1.6.2)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.2.3)
em-websocket (0.5.0)
erubis (2.7.0)
eventmachine (1.0.3)
execjs (2.0.2)
executable-hooks (1.2.3)
ffi (1.9.0)
formatador (0.2.4)
fssm (0.2.10)
guard (2.0.3)
guard-compass (1.0.0)
guard-haml (1.1.0)
guard-livereload (2.0.0)
haml (4.0.3)
hike (1.2.3)
http_parser.rb (0.5.3)
i18n (0.6.5)
jbuilder (1.5.1)
jquery-rails (3.0.4, 2.2.2)
json (1.8.0)
kindlerb (0.1.1)
listen (2.0.1)
lumberjack (1.0.4)
mail (2.5.4)
metaclass (0.0.1)
method_source (0.8.2)
mime-types (1.25)
mini_portile (0.5.1)
minitest (5.0.8, 4.7.5)
mocha (0.14.0)
multi_json (1.8.1)
mustache (0.99.4)
mysql (2.9.1)
mysql2 (0.3.13)
nokogiri (1.6.0)
polyglot (0.3.3)
pry (0.9.12.2)
racc (1.4.9)
rack (1.5.2)
rack-cache (1.2)
rack-test (0.6.2)
rails (4.0.0)
railties (4.0.0)
rake (10.1.0)
rb-fsevent (0.9.3)
rb-inotify (0.9.2)
rdoc (3.12.2)
redcarpet (2.2.2)
rubygems-bundler (1.3.4)
rvm (1.11.3.8)
sass (3.2.12)
sass-rails (4.0.0)
sdoc (0.3.20)
slop (3.4.6)
sprockets (2.10.0)
sprockets-rails (2.0.0)
sqlite3 (1.3.8)
thor (0.18.1)
thread_safe (0.1.3)
tilt (1.4.1)
timers (1.1.0)
treetop (1.4.15)
turbolinks (1.3.0)
tzinfo (0.3.38, 0.3.37)
uglifier (2.2.1)
w3c_validators (1.2)
web-console (1.0.3)
yajl-ruby (1.1.0)
database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Help please?
I found another cause for this error. While I had the mysql2 gem installed, in my model I specified the string "mysql" to establish_connection:
establish_connection adapter: "mysql", database: "my_database"
Obviously, it should be "mysql2" not "mysql".
SOLVED: This took me a while to figure out, and I blame the guide's fault. Anyways, make SURE you're editing the correct Gemfile, and to do a bundle install in the directory with the Gemfile that you changed. When I ran
$ cd rails
$ bundle exec rails new ~/my-test-app --dev
that actually created a folder called my-test-app (which contained a Gemfile) in my home directory but I had to run $ bundle exec rake test_sqlite3 in my rails directory (which also contained a Gemfile).
Looking at my output above, it said Gems in the group db were not installed. when I ran bundle install, and was referring to lines in my Gemfile that weren't executing, and they just so happened to be the gem lines that install mysql, mysql2, and postgresql. I corrected the file like so:
Gemfile
# AR
gem 'sqlite3', '~> 1.3.6'
gem 'mysql', '~> 2.9.1'
gem 'mysql2', '~> 0.3.13'
gem 'pg', '~> 0.17.0'
group :db do
# gem 'pg', '>= 0.11.0'
# gem 'mysql', '>= 2.9.0'
# gem 'mysql2', '>= 0.3.13'
end
I had the same problem. The solution was that i forgot to adapt the Gemfile accordingly. So change into the directory where you created your rails app, then open the Gemfile with sudo vim Gemfile.
There you have to add or remove certain gems, according to your needs.
In my case i had to exchange the db-gem "sqlite3" with "mysql".
After that, save the file with :wq and run rails generate [model/controller/view] <name> again.
That has done the job for me, hope it helps some of you!

Installing mysql2 0.3.13

I'm having trouble finding good instructions on how to install gem mysql2-0.3.13 and have it up and running for a ruby on rails application. Could anyone please break down this process? When I try to install the gem, I get this error:
I m using rails 3.2.13 and ruby 1.9.3 and mac OSX
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
/Users/sumitkalra1984/.rvm/gems/ruby-1.9.3-p448#global/gems/bundler-1.3.5/lib/bundler.rb:284: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Using rake (10.1.0)
Using i18n (0.6.5)
Using minitest (4.7.5)
Using multi_json (1.7.9)
Using atomic (1.1.13)
Using thread_safe (0.1.2)
Using tzinfo (0.3.37)
Using activesupport (4.0.0)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0)
Using mime-types (1.24)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.0)
Using activemodel (4.0.0)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.0)
Using activerecord (4.0.0)
Using thor (0.18.1)
Using railties (4.0.0)
Using activerecord-session_store (0.0.1)
Using bcrypt-ruby (3.1.1)
Using coffee-script-source (1.6.3)
Using execjs (2.0.0)
Using coffee-script (2.2.0)
Using coffee-rails (4.0.0)
Using daemons (1.1.9)
Using orm_adapter (0.4.0)
Using warden (1.2.3)
Using devise (3.0.3)
Using eventmachine (1.0.3)
Using multipart-post (1.2.0)
Using faraday (0.8.8)
Using hashie (2.0.5)
Using hike (1.2.3)
Using httpauth (0.2.0)
Using jbuilder (1.5.0)
Using jquery-rails (3.0.4)
Using json (1.8.0)
Using jwt (0.1.8)
Using libv8 (3.16.14.3)
Installing mysql2 (0.3.13)
Errno::EACCES: Permission denied - /Users/sumitkalra1984/.rvm/gems/ruby-1.9.3-p448/gems/mysql2-0.3.13/MIT-LICENSE
An error occurred while installing mysql2 (0.3.13), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.13'` succeeds before bundling.
If you have facing permission problem then install the gems as a root user
like
sudo bundle install
please check you have mysql installed properly
and for Mysql2 gem before installing the gem type
sudo apt-get install mysql-server libmysqlclient-dev libmysql-ruby
I am not a mac user but It work's in ubuntu. Hope this could help you.
I ran to the same problem. To fix this problem, open a command prompt. go to your application folder. And type: gem install mysql2 -v 0.3.11 this version is working great. this is for Windows.
I don't know if you are in my same situation. I've solved checking out if in my RVM there was a directory for mysql gem (probably generated from previous bundle commands). I've removed the folder and then i've run again bundle install.

Using Ruby and XEROUND on Heroku

First I would like to know if anyone has successfully built a Ruby on Rails application on Heroku using the XEROUND Add-on?
My PHP app works fine with the XEROUND Add-on (same database).
My Ruby application however, errors on starting.
We're sorry, but something went wrong.
On my development machine, When I run:
rails server -e production
the program starts with no problem.
When I push the code to Heroku and start the app
I get the Were sorry error.
Any ideas?
Is there anyway to output the database variables, right after they are assigned? As far as I know this would mean modifying the active-record adapter.
Is this a problem with Ruby itself? Should it have even gotten into the connection pool?
Would I be better off using XEROUND outside of Heroku (not as an Add-on)?
My database.yml contains
production:
adapter: mysql2
encoding: utf8
database: <%= ENV['XEROUND_DATABASE_NAME'] %>
username: <%= ENV['XEROUND_DATABASE_USERNAME'] %>
password: <%= ENV['XEROUND_DATABASE_PASSWORD'] %>
host: <%= ENV['XEROUND_DATABASE_HOST'] %>
port: <%= ENV['XEROUND_DATABASE_PORT'] %>
I get the same message when I hardcode the values.
Build information on Heroku:
git push heroku master
Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 1.19 KiB, done.
Total 10 (delta 7), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.1
Running: bundle install --without development:test --path vendor/bundle - -binstubs bin/
Fetching gem metadata from ....rubygems.org/.........
Using rake (0.9.2.2)
Using i18n (0.6.1)
Using multi_json (1.3.6)
Using activesupport (3.2.1)
Using builder (3.0.3)
Using activemodel (3.2.1)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.1)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.1)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.1)
Using mysql2 (0.3.11)
Using activerecord-mysql2-adapter (0.0.3)
Using activeresource (3.2.1)
Using bundler (1.2.1)
Using coffee-script-source (1.3.3)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.1)
Using coffee-rails (3.2.2)
Using jquery-rails (2.1.3)
Using rails (3.2.1)
Using sass (3.2.1)
Using sass-rails (3.2.5)
Using uglifier (1.3.0)
Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Detected manifest.yml, assuming assets were compiled locally
-----> Rails plugin injection
Injecting rails_log_stdout
Injecting rails3_serve_static_assets
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size: 8.7MB
-----> Launching... done, v18
....shielded-brushlands-3293.herokuapp.com deployed to Heroku
To git#heroku.com:shielded-brushlands-3293.git
73c5cb6..c391a47 master -> master
The Heroku log shows:
2012-09-30T00:58:10+00:00 app[web.1]: => Booting WEBrick
2012-09-30T00:58:10+00:00 app[web.1]: => Rails 3.2.1 application starting in production on ...0.0.0.0:6832
2012-09-30T00:58:10+00:00 app[web.1]: => Call with -d to detach
2012-09-30T00:58:10+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-09-30T00:58:10+00:00 app[web.1]: Started GET "/" for 76.87.97.210 at 2012-09-30 00:58:10 +0000
2012-09-30T00:58:15+00:00 heroku[router]: GET shielded-brushlands-3293.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=4529ms status=500 bytes=643
2012-09-30T00:58:15+00:00 app[web.1]: ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished):
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:26:in `call_app'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:16:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/log_tailer.rb:14:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/static.rb:53:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
2012-09-30T00:58:15+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-09-30T00:58:15+00:00 app[web.1]:
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/engine.rb:479:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/query_cache.rb:67:in `rescue in call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/application.rb:220:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: cache: [GET /] miss
2012-09-30T00:58:15+00:00 app[web.1]:
2012-09-30T00:58:15+00:00 app[web.1]:
2012-09-30T00:58:15+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/query_cache.rb:61:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `_run__2306900267479677068__call__3522025195442796026__callbacks'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-09-30T00:58:15+00:00 heroku[router]: GET shielded-brushlands-3293.herokuapp.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=17ms status=200 bytes=0
2012-09-30T00:58:15+00:00 app[web.1]: cache: [GET /favicon.ico] miss, store
The gemfile.lock
GEM
remote: ....rubygems.org/
specs:
actionmailer (3.2.1)
actionpack (= 3.2.1)
mail (~> 2.4.0)
actionpack (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.1)
activesupport (= 3.2.1)
builder (~> 3.0.0)
activerecord (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
arel (~> 3.0.0)
tzinfo (~> 0.3.29)
activerecord-mysql2-adapter (0.0.3)
mysql2
activeresource (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
activesupport (3.2.1)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.3)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.1.1)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.7.5)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.19)
multi_json (1.3.6)
mysql2 (0.3.11)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.1)
actionmailer (= 3.2.1)
actionpack (= 3.2.1)
activerecord (= 3.2.1)
activeresource (= 3.2.1)
activesupport (= 3.2.1)
bundler (~> 1.0)
railties (= 3.2.1)
railties (3.2.1)
actionpack (= 3.2.1)
activesupport (= 3.2.1)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.7)
execjs (>= 0.3.0)
multi_json (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
activerecord-mysql2-adapter
coffee-rails (~> 3.2.1)
jquery-rails
mysql2
rails (= 3.2.1)
sass-rails (~> 3.2.3)
uglifier (>= 1.0.3)
I did an internet search on: xeround heroku ruby
The first item on the list:
https://devcenter.heroku.com/articles/xeround
So if I can use heroku config to set variables, then I should be able to see all variables
Next search on: heroku config
The first item on the list:
https://devcenter.heroku.com/articles/config-vars
In the config-vars article (from 2nd search) I can issue the command: heroku config
heroku config
! autoupdate in progress
=== shielded-brushlands-3293 Config Vars
DATABASE_URL: postgres://hvsosprakvuedm:v5QU211mYByXbBIdAxa3s4oMff#ec2-107-20-195-105.compute-1.amazonaws.com:5432/dehgili4ph7ih7
GEM_PATH: vendor/bundle/ruby/1.9.1
LANG: en_US.UTF-8
PATH: bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
RACK_ENV: production
RAILS_ENV: production
XEROUND_DATABASE_ADAPTER: mysql
XEROUND_DATABASE_FAILOVER_ADAPTER: mysql
XEROUND_DATABASE_FAILOVER_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_FAILOVER_NAME: app7912272
XEROUND_DATABASE_FAILOVER_PASSWORD: xxxxx
XEROUND_DATABASE_FAILOVER_PORT: 16304
XEROUND_DATABASE_FAILOVER_URL: mysql://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_FAILOVER_USERNAME: app7912272
XEROUND_DATABASE_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_ADAPTER: mysql
XEROUND_DATABASE_INTERNAL_HOST: int.instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_NAME: app7912272
XEROUND_DATABASE_INTERNAL_PASSWORD: xxxxx
XEROUND_DATABASE_INTERNAL_PORT: 16304
XEROUND_DATABASE_INTERNAL_URL: mysql://app7912272:xxxx#int.instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_INTERNAL_USERNAME: app7912272
XEROUND_DATABASE_NAME: app7912272
XEROUND_DATABASE_PASSWORD: xxxxx
XEROUND_DATABASE_PORT: 16304
XEROUND_DATABASE_URL: mysql://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_USERNAME: app7912272
The first one caught my attention, its pointing to a postgres location.
Does it matter? I'm not referencing DATABASE_URL.
The xeround article (from 1st search) contained a line, but didn't get into why, it just said do it.
Connecting to xeround
The Xeround add-on will store the database’s URLs in two config vars:
XEROUND_DATABASE_URL and XEROUND_DATABASE_INTERNAL_URL
The “internal” URL is translated to internal IP addresses and should be used when accessing your database from within the same datacenter.
The first URL is used for connecting from outside.
Copy the value of the config variable that is relevant for you -
$ heroku config:add DATABASE_URL=(URL config vars)
Hmmm? It is not a variable I refrence in my program, nor is it set on my local machine.
Here it goes:
Since this is supposed to be a cloud database, I should not need to know anything about datacenter locations, so going with external.
heroku config:add DATABASE_URL=mysql://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
Setting config vars and restarting shielded-brushlands-3293... !
Autoupdate in progress
done, v20
DATABASE_URL: mysql://app7912272:XXXX#instance27464.db.xeround.com.:16304/app7912272
Lets see if it comes up....
Crap
Okay set it to internal:
heroku config:add DATABASE_URL=mysql://app7912272:xxxx#int.instance27464.db.xeround.com.:16304/app7912272
Lets see if it comes up....
Crap II
I also noticed there are two variables called XEROUND_DATABASE_ADAPTER, XEROUND_DATABASE_FAILOVER_ADAPTER and XEROUND_DATABASE_INTERNAL_ADAPTER.
They are both set to mysql.
I am using mysql2.
heroku config:add XEROUND_DATABASE_ADAPTER=mysql2
heroku config:add XEROUND_DATABASE_FAILOVER_ADAPTER=mysql2
herokU config:add XEROUND_DATABASE_INTERNAL_ADAPTER=mysql2
Lets see if it comes up....
Crap III
Further down in the article:
Each of the URLs contains a string of the following syntax:
mysql://username:password#host:port/database
The parts out of which the URLs are made of are also set for your convenience in the following environment variables:
XEROUND_DATABASE_ADAPTER
XEROUND_DATABASE_USERNAME
XEROUND_DATABASE_PASSWORD
XEROUND_DATABASE_HOST
XEROUND_DATABASE_PORT
XEROUND_DATABASE_NAME
XEROUND_DATABASE_INTERNAL_ADAPTER
XEROUND_DATABASE_INTERNAL_USERNAME
XEROUND_DATABASE_INTERNAL_PASSWORD
XEROUND_DATABASE_INTERNAL_HOST
XEROUND_DATABASE_INTERNAL_PORT
XEROUND_DATABASE_INTERNAL_NAME
Anyone who has been around programming long enough, probably knows where this is going. Sometimes you do things, even though they make no sense.
So the mysql: is derived from the adapter.
Update the url variables as well:
heroku config:add DATABASE_URL=mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
heroku config:add XEROUND_DATABASE_URL=mysql2://app7912272:xxxxxx#instance27464.db.xeround.com.:16304/app7912272
heroku config:add XEROUND_DATABASE_FAILOVER_URL=mysql2://app7912272:xxxxxx#instance27464.db.xeround.com.:16304/app7912272
herokU config:add XEROUND_DATABASE_INTERNAL_URL=mysql2://app7912272:xxxxxx#instance27464.db.xeround.com.:16304/app7912272
No crap, the application came up
A final look:
heroku config
! autoupdate in progress
=== shielded-brushlands-3293 Config Vars
DATABASE_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
GEM_PATH: vendor/bundle/ruby/1.9.1
LANG: en_US.UTF-8
PATH: bin:vendor/bundle/ruby/1.9.1/bin:/usr/local bin:/usr/bin:/bin
RACK_ENV: production
RAILS_ENV: production
XEROUND_DATABASE_ADAPTER: mysql2
XEROUND_DATABASE_FAILOVER_ADAPTER: mysql2
XEROUND_DATABASE_FAILOVER_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_FAILOVER_NAME: app7912272
XEROUND_DATABASE_FAILOVER_PASSWORD: xxxx
XEROUND_DATABASE_FAILOVER_PORT: 16304
XEROUND_DATABASE_FAILOVER_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_FAILOVER_USERNAME: app7912272
XEROUND_DATABASE_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_ADAPTER: mysql2
XEROUND_DATABASE_INTERNAL_HOST: int.instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_NAME: app7912272
XEROUND_DATABASE_INTERNAL_PASSWORD: xxxx
XEROUND_DATABASE_INTERNAL_PORT: 16304
XEROUND_DATABASE_INTERNAL_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_INTERNAL_USERNAME: app7912272
XEROUND_DATABASE_NAME: app7912272
XEROUND_DATABASE_PASSWORD: xxxx
XEROUND_DATABASE_PORT: 16304
XEROUND_DATABASE_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_USERNAME: app7912272
Since the mysql2 gem is the default w/ Rails 3 all you need to do is make sure you have "gem 'mysql2'" in your gemfile, and run bundle install, commit/push to heroku
Then of course use your URL listed in heroku config under "XEROUND_DATABASE_URL"
heroku config:add DATABASE_URL=mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
Note the changing the mysql:// to mysql2:// (this is the key)
Then
heroku restart
I JUST did this on a brand new Rails 3.2.9 Heroku app running Xeround with success. There was no need to change the adapter to "mysql2"

"undefined method `accept' for nil:NilClass"

I am getting "undefined method `accept' for nil:NilClass" error while running db:migrate. My configuration is:
Rails 3.2.8
MySql 5.1.54
OS : win7
ruby : 1.9.2
my gems list command output:
F:\RailsApp\MyApp>gem list
*** LOCAL GEMS ***
actionmailer (3.2.8)
actionpack (3.2.8)
activemodel (3.2.8, 3.1.0)
activerecord (3.2.8)
activeresource (3.2.8)
activesupport (3.2.8, 3.1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1 x86-mingw32)
builder (3.0.0)
bundler (1.1.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.3)
erubis (2.7.0)
execjs (1.4.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
json (1.7.4)
mail (2.4.4)
mime-types (1.19)
minitest (1.6.0)
multi_json (1.3.6)
mysql (2.8.1 x86-mingw32)
mysql2 (0.3.11 x86-mingw32, 0.2.6 x86-mingw32)
polyglot (0.3.3)
rack (1.4.1, 1.3.6)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.8)
railties (3.2.8)
rake (0.9.2.2, 0.8.7)
rdoc (3.12, 2.5.8)
sass (3.2.0)
sass-rails (3.2.5)
sprockets (2.1.3)
thor (0.15.4)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.7)
I have also copy the %MYSQLPATH%/bin/libmySQL.dll file to %RUBYHOME%/bin folder.
Can anybody pleas help me to solve this problem?
This may be a AR-JDBC issue. Try running
bundle update activerecord-jdbc-adapter
This may help you..
If it didn't work for you, try with
bundle update mysql2
For more info look into the GitHub Issue
I had the same issue fixed by correcting database.yml file. It was having adopter as mysql2 now I have correct it to mysql
Finally I have resolve the problem with reference to this post mysql2 gem compiled for wrong mysql client library.
What I have done is as follows:
download and extract the package from http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
remove all mysql/mysql2 gem and re-install mysql gem with this command:
gem install mysql --platform=ruby -- --with-mysql-dir=E:/mysql-connector-c-noinstall-6.0.2-win32
add gem 'mysql' in GemFile
modify database.yml with adapter:mysql
copy MYSQLHOME/bin/libmsql.dll to RUBYHOME/bin
if find dsl error then add require 'rake/dsl_definition' at top of RakeFile
and it works.. :-)
My final GemFile is:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'mysql'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'

Rails 3 - Incorrect MySQL client library version! Gem compiled for the wrong client library version

I cloned the github repo https://github.com/8bitpal/hackful, run 'bundle install' and now 'rake db:create'. But I get an error message:
Incorrect MySQL client library version! This gem was compiled for 5.0.45 but the client library is 5.5.15.
Tried to find out more infos about my mysql setup:
$ mysql_config --version
$ 5.0.45
$ mysql
$ mysql> SELECT version();
+-----------+
| version() |
+-----------+
| 5.1.57 |
+-----------+
Since I rarely do sysadmin stuff I feel a bit lost how to interpretate this info, i.e. why is the "client library 5.5.15" mentioned, is that kind of a minimum version mysql version when using the mysql2 gem?
Anyhow, I did some more research on SO and found this thread
Ruby mysql2 gem compiled for wrong mysql client library version. The question is similar to mine:
After updating MySQL to 5.5 using apt-get, the mysql2 gem stopped
working.
Here's the error:
Incorrect MySQL client library version! This gem was compiled for
5.5.17 but the client library is 5.1.58. (RuntimeError)
The answer in that thread:
I have encounter the same error when using Ubuntu Server 11.04 and
Percona Server, what have I done was:
replace /usr/lib/libmysqlclient.so.16.0.0 with
/usr/lib/libmysqlclient.so.18.0.0
Problem in my case is that I don't have such a file:
ls /usr/lib/mysql
libdbug.a libmyisam.a libmysqlclient.a libmysqlclient_r.a libmystrings.a libvio.a
libheap.a libmyisammrg.a libmysqlclient.la libmysqlclient_r.la libmysys.a
Most other threads with a similar topic are about Windows, but I'm on OS X. Any ideas what can I try next? More infos about my setup: OS X Lion, rvm, Rails 3.1.3, ruby 1.9.2p290. Gem list:
*** LOCAL GEMS ***
actionmailer (3.1.3)
actionpack (3.1.3)
activemodel (3.1.3)
activerecord (3.1.3)
activeresource (3.1.3)
activesupport (3.1.3)
addressable (2.2.7)
arel (2.2.1)
bcrypt-ruby (3.0.1)
builder (3.0.0)
bundler (1.0.21)
cancan (1.6.5)
capybara (1.1.2)
capybara-webkit (0.10.1)
childprocess (0.3.0)
coderay (1.0.5)
coffee-rails (3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
cucumber (1.1.4)
cucumber-rails (1.2.1)
database_cleaner (0.7.1)
delayed_job (3.0.0)
delayed_job_active_record (0.3.1)
devise (2.0.0)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.3.0)
factory_girl (2.6.3)
factory_girl_rails (1.7.0)
faker (1.0.1)
fakeweb (1.3.0)
ffi (1.0.11)
fileutils (0.7)
gherkin (2.7.6)
growl (1.0.3)
guard (1.0.3)
guard-bundler (0.1.3)
guard-cucumber (0.7.5)
guard-rspec (0.7.2)
guard-spork (0.8.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
json (1.6.5)
launchy (2.0.5)
libv8 (3.3.10.4 x86_64-darwin-11)
mail (2.3.0)
make_voteable (0.1.1)
method_source (0.7.1)
mime-types (1.17.2)
multi_json (1.0.4)
mysql (2.8.1)
mysql2 (0.3.11)
nokogiri (1.5.0)
orm_adapter (0.0.6)
polyglot (0.3.3)
pry (0.9.8.4)
rack (1.3.6)
rack-cache (1.1)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.3)
rails_autolink (1.0.5)
railties (3.1.3)
rake (0.9.2.2)
rb-fsevent (0.9.1)
rdiscount (1.6.8)
rdoc (3.12)
rest-client (1.6.7)
rmagick (2.13.1)
rspec (2.8.0)
rspec-core (2.8.0)
rspec-expectations (2.8.0)
rspec-mocks (2.8.0)
rspec-rails (2.8.1)
rubyzip (0.9.5)
sass (3.1.12)
sass-rails (3.1.5)
selenium-webdriver (2.18.0)
slop (2.4.4)
spork (0.9.2)
sprockets (2.0.3)
sqlite3 (1.3.5)
term-ansicolor (1.0.7)
therubyracer (0.9.9)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)
uglifier (1.2.2)
warden (1.1.0)
xpath (0.1.4)
Update
I checked what homebrew installed for mysql. When I understood it correct, this should be the mysql client library version:
$ ls /usr/local/Cellar/mysql
$ 5.5.15
Now I need to get the mysql_config updated to 5.5.15?
Update 2
Solved. This one did the trick:
gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.15/bin/mysql_config
Source: Install the mysql2 gem for a specific mysql client version?
Had this problem after upgrading packages in homebrew. The mysql2 gem simply needs to be told to re-compile its non-ruby components.
Assuming homebrew is set up correctly, the following should fix the problem:
gem uninstall mysql2
gem install mysql2 # or bundle install
(depending on your bundler config, you may need to do something more complicated, but this was enough for me)
I have solved the problem based on this tutorial, which helped me installing the correct version of mysql for rails
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/