ActiveRecord::StatementInvalid Mysql::Error

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:inexecute’
/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:inselect_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:infind_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:inlist’
/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:inperform_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:inperform_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:inperform_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:insend’
/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:inprocess_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:indispatch’
/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:inprocess!’
/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:ineach’
/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:inprocess!’
/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 :frowning:

I don’t really understand where is the problem

Can somebody help me?

Thanks,
Suja

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.

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.

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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs