Ruby Forum Ruby on Rails > ActiveRecord::StatementInvalid Mysql::Error

Posted by Suja JS (suja)
on 12.05.2008 13:56
Hi,

I was deploying my application on my server, when i test my application
i can see this error

ActiveRecord::StatementInvalid (Mysql::Error: MySQL client ran out of
memory: SELECT * FROM contacts ):
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
`log'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/mysql_adapter.rb:184:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/mysql_adapter.rb:336:in
`select'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/mysql_adapter.rb:175:in
`select_all'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:390:in
`find_by_sql'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:924:in
`find_every'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:381:in
`find'
/app/controllers/contacts_controller.rb:38:in `list'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
`send'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
`perform_action_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in
`perform_action_without_benchmark'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in
`perform_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
`send'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
`process_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in
`process_without_session_management_support'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in
`process'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in
`dispatch'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:150:in
`process_request'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:54:in
`process!'
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:600:in
`each_cgi'
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:597:in `each'
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:597:in
`each_cgi'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:53:in
`process!'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:23:in
`process!'
/public/dispatch.fcgi:24


Perhaps in my development environement i don't have this problem :(

I don't really understand where is the problem

Can somebody help me?

Thanks,
Suja
Posted by AndyV (Guest)
on 12.05.2008 21:06
(Received via mailing list)
Do you have the same data in production and development?  I don't mean
to be pedantic, but the message pretty clearly suggests you've run out
of memory.  If you're dealing with a larger data set in production
that may not be unexpected.  You'll probably need to look into
using :limit, :offset, and paging through the data.
Posted by Suja JS (suja)
on 13.05.2008 09:32
AndyV wrote:
> Do you have the same data in production and development?  I don't mean
> to be pedantic, but the message pretty clearly suggests you've run out
> of memory.  If you're dealing with a larger data set in production
> that may not be unexpected.  You'll probably need to look into
> using :limit, :offset, and paging through the data.

contact table contains only 2993 record.
Posted by Suja JS (suja)
on 13.05.2008 14:29
AndyV wrote:
> Do you have the same data in production and development?  I don't mean
> to be pedantic, but the message pretty clearly suggests you've run out
> of memory.  If you're dealing with a larger data set in production
> that may not be unexpected.  You'll probably need to look into
> using :limit, :offset, and paging through the data.

This error occurs randomly (ActiveRecord::StatementInvalid 
(Mysql::Error: MySQL client ran out of memory: SELECT * FROM contacts 
)). 'contact' table contains only 2993 record. When I give limit 1000 it 
works. But when I give limit 2000 it show 'ran out of memory' error.
Posted by AndyV (Guest)
on 13.05.2008 16:20
(Received via mailing list)
If you get it consistenly with a limit of 2000 that does not sound
'random' to me.

The important point was that the differing data (development vs
production) is what is leading to the differing results.  You have
more data in production and the way you've developed this contact
interface is causing it to run out of memory in production.  You will
need to find a way to set an appropriate 'page' size and page your way
through the data.

This makes a lot of pragmatic sense -- it's unlikely that your user
will be able to deal with 3k records.  It will all be noise.

Check out the will_paginate gem/plugin.