Closed morszczuk closed 5 years ago
The stackrace of error ends at the execution of the native extension functions. I tried to debug C code and apparently 'executing in another thread' error comes from oci8_call_without_gvl function (in ext/oci8lib.c file). What can be the reason of this error?
I don't know the reason. One database connection cannot be used from more than one thread at the same time. So when a connection is used while it is used in another thread, ruby-oc8 raises the error. The behavior has not been changed since ruby-oci8 2.0.0 until now. Therefore what I could say is that the caller should not use one connection simultaneously. However rails supports connection pooling and uses one connection from only one thread. So the error won't occur.
@kubo Thank you very much for your response. Although we haven't found what causes our problem yet, we now know the place to investigate - our issue is probably related to how feature tests are being run. Thanks!
Hey @morszczuk! Was wondering if you found out what was causing the error? We are getting this same error after upgrading to Rails 6 (6.0.4.6) using ruby-oci8 (2.2.9) & activerecord-oracle_enhanced-adapter (= 6.0.4)
We have been able to re-created the issue by executing queries in the same number of threads as our connection pool is configured for.
@cbenger
Could you try ruby-oci8 2.2.10 or later? @poblouin found that https://github.com/kubo/ruby-oci8/commit/031cab52f95e9d3ea5229ed0e465c95a7e94dcaa, which is in ruby-oci8 2.2.10 or later, solved the issue. See https://github.com/kubo/ruby-oci8/issues/244.
Hi @kubo! Yeah, upgrading to 2.2.10 did fix the issue. Poblouin and I are actually co-workers haha. Wanted to ask here incase the OP on this ticket ever found what was causing this error for them.
Hi Team
I am getting similar error while running ApplicationSystemTestCase. The changes made to the app before getting these errors are.
ruby-oci8 seems to be 2.2.11
Error output
Minitest::UnexpectedError: RuntimeError: executing in another thread
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/ruby-oci8-2.2.11/lib/oci8/cursor.rb:131:in `__execute'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/ruby-oci8-2.2.11/lib/oci8/cursor.rb:131:in `exec'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/ruby-oci8-2.2.11/lib/oci8/oci8.rb:271:in `exec_internal'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/ruby-oci8-2.2.11/lib/oci8/oci8.rb:262:in `exec'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-oracle_enhanced-adapter-7.0.3/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:401:in `ping'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-oracle_enhanced-adapter-7.0.3/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:81:in `ping'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-oracle_enhanced-adapter-7.0.3/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:443:in `active?'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract_adapter.rb:579:in `verify!'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:705:in `block in checkout_and_verify'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.1/lib/active_support/callbacks.rb:107:in `run_callbacks'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.1/lib/active_support/callbacks.rb:929:in `_run_checkout_callbacks'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:704:in `checkout_and_verify'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in `checkout'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `connection'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8.1/lib/active_record/test_fixtures.rb:192:in `map'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8.1/lib/active_record/test_fixtures.rb:192:in `enlist_fixture_connections'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8.1/lib/active_record/test_fixtures.rb:130:in `setup_fixtures'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.0.8.1/lib/active_record/test_fixtures.rb:10:in `before_setup'
/Users/eroza001/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.1/lib/active_support/testing/setup_and_teardown.rb:40:in `before_setup'
This is not a show stopper. I thought it will be helpful to let you guys know.
Thank you
Dear Kubo,
In our project, we are experiencing randomly occurring 'executing in another thread' error. It shows up in the feature tests (run with the usage of Capybara) and is more likely to happen when there are many interactions with the database at the same time. I know we are using older version of the gem - we are working on moving to the newer versions of rails and oci8 gem. But before that happens, do you think you can give some tips what can cause our problems?
The stackrace of error ends at the execution of the native extension functions. I tried to debug C code and apparently 'executing in another thread' error comes from
oci8_call_without_gvl
function (in ext/oci8lib.c file). What can be the reason of this error?Ruby version:
2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Rails version:
4.2.11.1
ruby-oci8lib gem version:
2.1.7
Database version:
Oracle 12c
Error:
Gem versions: