Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translate
ORA-00060
into ActiveRecord::Deadlocked
error
This PR translates `ORA-00060` into `ActiveRecord::Deadlocked` error. Added an `ORA-00060` reproduction test case equivalent to activerecord/test/cases/adapters/mysql2/transaction_test.rb. https://github.com/rails/rails/blob/8f2490b57f488ed60fc6e0a201ccd5e66811ab51/activerecord/test/cases/adapters/mysql2/transaction_test.rb#L36-L61 The following is a reproduce testing log. ```console % bundle exec rspec ./spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb:575 (snip) 1) OracleEnhancedAdapter Transaction Raises Deadlocked when a deadlock is encountered Failure/Error: expect { barrier = Concurrent::CyclicBarrier.new(2) t1 = TestPost.create(title: "one") t2 = TestPost.create(title: "two") thread = Thread.new do TestPost.transaction do t1.lock! barrier.wait expected ActiveRecord::Deadlocked, got #<ActiveRecord::StatementInvalid: OCIError: ORA-00060: deadlock detected while waiting for resource: UPDATE "TEST_POSTS" SET "TITLE" = :a1 WHERE "TEST_POSTS"."ID" = :a2> with backtrace: ``` And this commit resolves `Java::JavaSql::SQLException` exception. `Java::JavaSql::SQLException` is not `NativeException`. https://travis-ci.org/rsim/oracle-enhanced/jobs/301301765 It seems to be a potential issue caused by not passing test `OracleEnhanced::JDBCConnection#error_code` in rails/activerecord tests.
- Loading branch information