Mysql2::Error: SAVEPOINT active_record_1 does not exist


I’m switching the database of a rails 3 app I have developed from
postgres to mysql so that I can avail of amazon’s rds. Before I make
the change I have been running my test code using mysql on my dev
machine with the mysql2 adaptor . My test code is throwing up some
errors that I haven’t quite been able to get to the bottom of yet.
Basically I have a model that is used to store large xml uploads. My
test code looks something like this

test “creates forest units all should be okay” do
file =“test/files/lib/upload_sample.xml”)
upload = XmlUpload.create(:xml_contents => contents =


The create line is throwing up the following error

ActiveRecord::StatementInvalid: Mysql2::Error: SAVEPOINT
active_record_1 does not exist: ROLLBACK TO SAVEPOINT active_record_1
active_record/connection_adapters/abstract_adapter.rb:202:in rescue in log' /Users/conor/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/ active_record/connection_adapters/abstract_adapter.rb:194:inlog’
active_record/connection_adapters/mysql2_adapter.rb:314:in execute' /Users/conor/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.6/lib/ active_record/connection_adapters/mysql2_adapter.rb:358:inrollback_to_savepoint’
149:in rescue in transaction' /Users/conor/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/ active_record/connection_adapters/abstract/database_statements.rb: 127:intransaction’
active_record/transactions.rb:204:in transaction' /Users/conor/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/ active_record/transactions.rb:287:inwith_transaction_returning_status’
active_record/transactions.rb:237:in block in save' /Users/conor/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/ active_record/transactions.rb:248:inrollback_active_record_state!’
active_record/transactions.rb:236:in save' /Users/conor/Documents/treeMetrics/TreeMetricsFrontEnd/test/unit/ xml_upload_test.rb:42:inblock in class:XmlUploadTest

I have been storing the file contents in a text field. I realise that
I should seriously look at storing the files in s3 but this is the
setup that I have at the moment. In postgres everything worked fine
but in order to get things to work with mysql I had to set the :limit
variable so that LONGTEXT was used instead of the standard text
field. The files can be quite large but when I test using small files
there are no problems

I could be barking up the wrong tree entirely but I suspect that the
problem may be caused by the database connection being dropped based
on the errors thrown up when I try uploading a file in the development

Mysql2::Error: MySQL server has gone away: INSERT INTO

My database.yaml settings are the following

adapter: mysql2
encoding: utf8
reconnect: true
database: app_dev
username: username
password: password
host: localhost

adapter: mysql2
encoding: utf8
reconnect: true
database: app_test
username: username
password: password
host: localhost

Does anyone have any clues as to what the problem is and how it can
fixed? Any help with this would be greatly appreciated


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