views:

580

answers:

3

I get a mysql error:

#update (ActiveRecord::StatementInvalid) "Mysql::Error: #HY000Got error 139 from storage engine:

When trying to update a text field on a record with a string of length 1429 characters, any ideas on how to track down the problem?

Below is the stacktrace.

from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:147:in `log'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:299:in `execute'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:167:in `update_sql'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:314:in `update_sql'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:49:in `update_without_query_dirty'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:19:in `update'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/base.rb:2481:in `update_without_lock'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb:70:in `update_without_dirty'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/dirty.rb:137:in `update_without_callbacks'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/callbacks.rb:234:in `update_without_timestamps'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/timestamp.rb:38:in `update'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/base.rb:2472:in `create_or_update_without_callbacks'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/callbacks.rb:207:in `create_or_update'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/base.rb:2200:in `save_without_validation'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/validations.rb:901:in `save_without_dirty'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/dirty.rb:75:in `save_without_transactions'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:106:in `save'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:79:in `transaction'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:98:in `transaction'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:106:in `save'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `rollback_active_record_state!'
from /var/www/releases/20081002155111/vendor/rails/activerecord/lib/active_record/transactions.rb:106:in `save'
A: 

Maybe it's this bug: #1030 - Got error 139 from storage engine, but it would help if you'd post the query which should come directly after the error message.

MattW.
The query doesn't get logged in the terminal, will hunt down the mysql logs. And as for the mysql ticket, I'm only updating one text field with a string of length 1429, surely it can handle that (can't it!?)?
MatthewFord
The query should be in logs/development.log
MattW.
The app is in production and the logs just show the above stack trace. I cannot duplicate the problem in development
MatthewFord
A: 

It seemed to be a very weird mysql error, where the text was being truncated to 256 characters (for a text type) and throwing the above error is the string was 1000 characters or more. modifying the table column to be text again fixed the issue, or it just fixed it self.. i'm still not sure.

Update: Changing the table type to MyISAM fixed this problem

MatthewFord
+1  A: 

When you say a text field, is it of type VARCHAR, or TEXT?

If its the former then you cannot store a string larger than 255 chars (possibly less with UTF-8 overhead) in that column. If its the latter, you'd better post your schema definition so people can assist you further.

Dave Cheney