Adam-
First make certain you are using the C mysql bindings and not the
pure ruby ones. Also try putting this in your merb_init.rb:
Thread.new { loop { ActiveRecord::Base.verify_active_connections!;
sleep 60*60} }.priority = -10
That will wake up every hour and ping the db to make sure it doesn''t
disconnect.
Cheers-
-Ezra
On Oct 30, 2007, at 10:01 AM, Adam Roth wrote:
> Hello,
>
> Once or twice a day I''m losing connection to MySQL and this error
is
> generated:
>
> Mysql::Error: Lost connection to MySQL server during query: INSERT
> INTO pictures (`content_type`, `name`, `size`, `thumbnail`,
> `updated_at`, `pictureable_type`, `description`, `pictureable_id`,
> `filename`, `height`, `user_id`, `parent_id`, `created_at`, `width`)
> VALUES(''image/jpeg'', NULL, 70907, NULL,
''2007-10-30 00:25:36'', ''-'',
> NULL, 43, '' DSC05209.JPG'', 525, 1, NULL,
''2007-10-30 00:25:36'', 700)
> - (ActiveRecord::StatementInvalid)
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> connection_adapters/abstract_adapter.rb:128:in `log''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> connection_adapters/mysql_adapter.rb:243:in `execute''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> connection_adapters/mysql_adapter.rb:253:in `insert''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> base.rb:1814:in `create_without_callbacks''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> callbacks.rb:254:in `create_without_timestamps''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> timestamp.rb:30:in `create''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> base.rb:1792:in `create_or_update_without_callbacks''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> callbacks.rb:242:in `create_or_update''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> base.rb:1548:in `save_without_validation''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> validations.rb:752:in `save_without_transactions''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> transactions.rb:129:in `save''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> connection_adapters/abstract/database_statements.rb:59:in
> `transaction''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> transactions.rb:95:in `transaction''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> transactions.rb:121:in `transaction''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/
> transactions.rb:129:in `save''
> /u/apps/splat_upload/app/controllers/upload.rb:13:in `do''
>
> (The connection doesn''t restore)
>
> Very simple setup, cluster of 3...
>
> ...I''m using Merb for image uploads. I also have this exact same
> setup on another site and I never lose connection. Is there a work-
> around for this? Any ideas?
>
> Thanks
>
>
> _______________________________________________
> Merb-devel mailing list
> Merb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/merb-devel
Ezra Zygmuntowicz
Founder & Ruby Hacker
ezra at engineyard.com
EngineYard.com