Discussion Forums
- Topic List
- Most Recent Posts
- Sign In for more options
Hello,
I need help for following Mysql problem :
@slugs = Slug.all ActiveRecord::StatementInvalid: Mysql::Error: MySQL server has gone away: SELECT * FROM
slugsfrom /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:320:in `execute' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:595:in `select' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:661:in `find_by_sql' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1553:in `find_every' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:615:in `find' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:635:in `all' from (irb):6
I don't know how to resolve this problem.. !
Error is : "::StatementInvalid: Mysql::Error: MySQL server has gone away: "
Basically facing this problem while I'm working on the ruby Console of myproject.
After this error each time I have to reload console then only I can proceed further work..
Not getting exactly why?
I'm using Ruby 1.8.7, Rails - 2.3.2
Thanks in advance..!
- Ganesh Kathare.
i am not sure but are u using diffrent rails version .. ??
Hi Amit,
My current development environment is like:
About your application's environment Ruby version 1.8.7 (x86_64-linux) RubyGems version 1.3.1 Rack version 1.0 bundled Rails version 2.3.2 Active Record version 2.3.2 Action Pack version 2.3.2 Active Resource version 2.3.2 Action Mailer version 2.3.2 Active Support version 2.3.2 Application root /home/ilmatrim/public_html/new-cms Environment development Database adapter mysql Database schema version 20091120142722
. .
Many thanks for your cooperation..!
:)
Hi Amit,
I have resolved my Mysql Problem Using following Exception Handler Code :
I have added re_connect.rb file into /cofing/initializers/ dir of myProject with bellow code,
module ActiveRecord::ConnectionAdapters class MysqlAdapter
alias_method :execute_without_retry, :execute
def execute(*args)
execute_without_retry(*args)
rescue ActiveRecord::StatementInvalid => e
if e.message =~ /server has gone away/i
warn "Server timed out, retrying"
reconnect!
retry
else
raise e
end
end
end end
This code can 1 handle Mysql exception 2 then reconnect your db with ur poroject 3 and auto retry to ur reqest.
. . . I hope this will helps to other people
Cheerss!
Increase the pool size in database.yml
eg. pool: 8
