Michael Schoen
2006-Jul-07 14:27 UTC
Rails AR/Oracle Unit Test: [4574] failed (but getting better)
"bitsweat" has given AR/Oracle some love, but it''s still unhappy... http://dev.rubyonrails.org/changeset/4574 ------------------------------------------------------------------------ r4574 | bitsweat | 2006-07-07 03:42:14 -0700 (Fri, 07 Jul 2006) | 1 line Oracle: use nonblocking queries if allow_concurrency is set, fix pessimistic locking, don''t guess date vs. time by default (set OracleAdapter.emulate_dates = true for the old behavior), adapter cleanup. Closes #5635. ------------------------------------------------------------------------ U activerecord/test/associations_test.rb U activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb U activerecord/lib/active_record/connection_adapters/oracle_adapter.rb U activerecord/CHANGELOG Updated to revision 4574. 1) Failure: test_sane_find_with_lock(PessimisticLockingTest) [./test/locking_test.rb:90]: Exception raised: Class: <ActiveRecord::StatementInvalid> Message: <"OCIError: ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.: select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM people WHERE (people.id = 1) ) raw_sql_ where rownum <= 1) where raw_rnum_ > 0 FOR UPDATE"> ---Backtrace--- ./test/../lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log'' ./test/../lib/active_record/connection_adapters/oracle_adapter.rb:250:in `execute'' ./test/../lib/active_record/connection_adapters/oracle_adapter.rb:450:in `select'' ./test/../lib/active_record/connection_adapters/oracle_adapter.rb:241:in `select_all'' ./test/../lib/active_record/base.rb:422:in `find_by_sql'' ./test/../lib/active_record/base.rb:956:in `find_every'' ./test/../lib/active_record/base.rb:950:in `find_initial'' ./test/../lib/active_record/base.rb:984:in `find_one'' ./test/../lib/active_record/base.rb:973:in `find_from_ids'' ./test/../lib/active_record/base.rb:414:in `find'' ./test/locking_test.rb:93:in `test_sane_find_with_lock'' ./test/../lib/active_record/base.rb:905:in `with_scope'' ./test/locking_test.rb:92:in `test_sane_find_with_lock'' ./test/../lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'' ./test/../lib/active_record/transactions.rb:86:in `transaction'' ./test/locking_test.rb:91:in `test_sane_find_with_lock'' ./test/locking_test.rb:90:in `test_sane_find_with_lock'' --------------- 2) Failure: test_sane_lock_method(PessimisticLockingTest) [./test/locking_test.rb:101]: Exception raised: Class: <ActiveRecord::StatementInvalid> Message: <"OCIError: ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.: select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT * FROM people WHERE (people.id = 1) ) raw_sql_ where rownum <= 1) where raw_rnum_ > 0 FOR UPDATE"> ---Backtrace--- ./test/../lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log'' ./test/../lib/active_record/connection_adapters/oracle_adapter.rb:250:in `execute'' ./test/../lib/active_record/connection_adapters/oracle_adapter.rb:450:in `select'' ./test/../lib/active_record/connection_adapters/oracle_adapter.rb:241:in `select_all'' ./test/../lib/active_record/base.rb:422:in `find_by_sql'' ./test/../lib/active_record/base.rb:956:in `find_every'' ./test/../lib/active_record/base.rb:950:in `find_initial'' ./test/../lib/active_record/base.rb:984:in `find_one'' ./test/../lib/active_record/base.rb:973:in `find_from_ids'' ./test/../lib/active_record/base.rb:414:in `find'' ./test/../lib/active_record/base.rb:1561:in `reload'' ./test/../lib/active_record/locking/pessimistic.rb:72:in `lock!'' ./test/locking_test.rb:105:in `test_sane_lock_method'' ./test/../lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'' ./test/../lib/active_record/transactions.rb:86:in `transaction'' ./test/locking_test.rb:102:in `test_sane_lock_method'' ./test/locking_test.rb:101:in `test_sane_lock_method'' --------------- 905 tests, 3179 assertions, 2 failures, 0 errors rake aborted! Command failed with status (1): [/usr/pkg/ruby184/bin/ruby -Ilib:test:test/...] (See full trace by running task with --trace)
Michael A. Schoen
2006-Jul-07 14:34 UTC
Re: Rails AR/Oracle Unit Test: [4574] failed (but getting better)
Michael Schoen wrote:> "bitsweat" has given AR/Oracle some love, but it''s still unhappy... > > http://dev.rubyonrails.org/changeset/4574Thanks for applying the patch. One diff (below) was left out though, which is why the test is still failing. Using find_every().first skips the unnecessary (in this case, since this is within #find_one and the condition is a single value for the primary key) limit option, which is both slightly faster for Oracle, and allows for pessimistic locking. Index: activerecord/lib/active_record/base.rb ==================================================================--- activerecord/lib/active_record/base.rb (revision 4577) +++ activerecord/lib/active_record/base.rb (working copy) @@ -981,7 +981,7 @@ - if result = find_initial(options) + if result = find_every(options).first