Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In rails3/jruby, what could cause this error intermittently? SAVEPOINT active_record_1 does not exist

These errors do not occur when a single individual tests the system. But with a jmeter test, I can pretty reliably reproduce a few errors along the lines of:

ActiveRecord::JDBCError: SAVEPOINT active_record_1 does not exist: ROLLBACK TO SAVEPOINT active_record_1

Stack:

    gems/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `log'
    gems/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract_adapter.rb:200:in `log'
    gems/gems/activerecord-jdbc-adapter-1.2.1/lib/arjdbc/jdbc/adapter.rb:208:in `execute'
    gems/gems/activerecord-jdbc-adapter-1.2.1/lib/arjdbc/mysql/adapter.rb:156:in `rollback_to_savepoint'
    gems/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/database_statements.rb:179:in `transaction'
    gems/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/database_statements.rb:171:in `transaction'
    gems/gems/activerecord-3.0.10/lib/active_record/transactions.rb:207:in `transaction'
    gems/gems/activerecord-3.0.10/lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
    gems/gems/activerecord-3.0.10/lib/active_record/transactions.rb:240:in `save'
    gems/gems/activerecord-3.0.10/lib/active_record/transactions.rb:251:in `rollback_active_record_state!'
    gems/gems/activerecord-3.0.10/lib/active_record/transactions.rb:239:in `save'
    ...(our code that simply calls save on a new instance of a model class)...

We are not nesting transactions or even using them explicitly. I find one existing bug around this error message, but it is not relevant; we are not truncating or doing any DDL work. Merely creating a record and saving it.

We use Rails 3.0.10, JRuby 1.6.5, activerecord-jdbcmysql-adapter, warbled with Warbler 1.3.2 and deployed via Elastic Beanstalk on 64-bit Tomcat 7/Amazon RDS with a single Mysql instance, v5.1.57. We are set for config.threadsafe! - and this feels like a race of some kind in the bowels of ActiveRecord - but ActiveRecord is supposed to work in threadsafe, no?

One final note: I fear this is a JRuby or Warbler problem, because we cannot reproduce this problem if we switch from JRuby to MRI Ruby 1.9.

like image 974
David W Avatar asked Nov 13 '22 13:11

David W


1 Answers

It could be related to this commit, which was introduced in 1.2.1. Does 1.2.0 give you the same issue?

Maybe I need to reintroduce some error checking for transactions supported vs. failed transaction. Care to file a bug at https://github.com/jruby/activerecord-jdbc-adapter/issues? Thanks.

like image 158
Nick Sieger Avatar answered Dec 19 '22 16:12

Nick Sieger