I can consistently reproduce a hang in the following place.
--> #0 /usr/lib/ruby/gems/1.8/gems/ruby-debug-base-0.9.3/lib/ruby- debug-base.rb:74 in 'interrupt_last' #1 /usr/lib/ruby/gems/1.8/gems/ruby- debug-0.9.3/bin/rdebug:100 #2 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/vendor/mysql.rb:1094 in 'read' #3 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/vendor/mysql.rb:514 in 'read' #4 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/vendor/mysql.rb:396 in 'read_query_result' #5 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/vendor/mysql.rb:194 in 'real_query' #6 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/vendor/mysql.rb:322 in 'query' #7 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/mysql_adapter.rb:243 in 'execute' #8 /usr/lib/ruby/1.8/benchmark.rb:307 in 'realtime' #9 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/abstract_adapter.rb:110 in 'log' #10 /usr/lib/ruby/gems/1.8/gems/activerecord- 1.15.3/lib/ active_record/connection_adapters/mysql_adapter.rb:243 in 'execute' #11 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/mysql_adapter.rb:275 in 'rollback_db_transaction' #12 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/abstract/database_statements.rb:64 in 'transaction' #13 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/transactions.rb:95 in '' #14 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/transactions.rb:121 in 'transaction' #15 /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/transactions.rb:133 in 'save!' #16 (eval):6 #17 /usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/runner.rb: 45 in 'read' #18 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27 in 'require' #19 /tmp/test/script/runner:3
Here is a way to test it.
cd /tmp rails test cd test script/generate model example data:binary sed -i 's/:binary/:binary, :limit=>128.megabyte/' db/migrate/ 001_create_examples.rb echo "create database test_development;" | mysql -u root rake db:migrate echo -e 'data = ""\n25.megabyte.times { data << " " }\nexample = Example.new\nexample.data = data\nputs "save"\nexample.save!' > break rdebug /tmp/test/script/runner break
Type "c" at the rdb prompt to start the script. If you don't have rdebug, run "gem install ruby-debug". Give the script about 10-15 seconds more after it prints "save". Hit Ctrl+C. Type "w" at the rdb prompt to see a stack trace. It should be similar to the above trace.
To clean up:
echo "drop database test_development;" | mysql -u root cd .. rm -rf test
I don't understand why it hangs. I also don't understand why it is trying to rollback the transaction. As evidenced by the migration, we set the limit to 128 megabytes. We are trying to add 25 megabytes of data here. Why should it hang?
Here is some more information. $ uname -a Linux gicodex2 2.6.20-16-generic #2 SMP Thu Jun 7 20:19:32 UTC 2007 i686 GNU/Linux $ cat /etc/issue.net Ubuntu 7.04 $ rails --version Rails 1.2.3 $ mysql --version mysql Ver 14.12 Distrib 5.0.38, for pc-linux-gnu (i486) using readline 5.2
I would appreciate any information on how to prevent hangs on large blocks of data like this.
Thank you, Rusty Burchfield