Ruby + MySql weirdness

I’m posting this because I didn’t see any quick answers on google when looking for other people having my problem.  Recently all the unit tests for one of my Ruby on Rails projects started failing mysteriously.  The continuous integration server didn’t report any problems, but on my windows dev box (where I use instant rails) nothing would pass.  The errors came out like:

 15) Error:test_update(Admin::ConnectionControllerTest):ActiveRecord::StatementInvalid: Mysql::Error: Lost connection to MySQL server during query: DELETE FROM connections    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/mysql_adapter.rb:184:in `execute'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/mysql_adapter.rb:199:in `delete'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/fixtures.rb:283:in `delete_existing_fixtures'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/fixtures.rb:256:in `create_fixtures'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/fixtures.rb:256:in `create_fixtures'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/fixtures.rb:255:in `create_fixtures'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:794:in `silence'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/fixtures.rb:248:in `create_fixtures'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/fixtures.rb:565:in `load_fixtures'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/fixtures.rb:512:in `setup_with_fixtures'    c:/dev/fritz/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/fixtures.rb:547:in `setup'

The problem apparently is caused by the fact that I put a password on the mysql login credentials in the test environment.  Removing the password on the login made it work just fine.  So I guess something about the ruby mysql driver didn’t like the way my mysql server was configured.  Anyway, upgrading to Mysql 5.0 (from 4.1) fixed everything.  Not sure if this is a problem with the version of instant rails I have, or something about my database config, or if one of the libraries autoupdated to a non-compatible version, but it’s fixed now so I don’t much care.

Hope this helps anybody else out there who runs into a similar problem.

Leave a Reply