{"action":"created","issue":{"url":"https://api.github.com/repos/kubo/ruby-oci8/issues/86","repository_url":"https://api.github.com/repos/kubo/ruby-oci8","labels_url":"https://api.github.com/repos/kubo/ruby-oci8/issues/86/labels{/name}","comments_url":"https://api.github.com/repos/kubo/ruby-oci8/issues/86/comments","events_url":"https://api.github.com/repos/kubo/ruby-oci8/issues/86/events","html_url":"https://github.com/kubo/ruby-oci8/issues/86","id":95361941,"number":86,"title":"Getting OCIBreak: Canceled by user request","user":{"login":"rporrasluc","id":1927062,"avatar_url":"https://avatars.githubusercontent.com/u/1927062?v=3","gravatar_id":"","url":"https://api.github.com/users/rporrasluc","html_url":"https://github.com/rporrasluc","followers_url":"https://api.github.com/users/rporrasluc/followers","following_url":"https://api.github.com/users/rporrasluc/following{/other_user}","gists_url":"https://api.github.com/users/rporrasluc/gists{/gist_id}","starred_url":"https://api.github.com/users/rporrasluc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rporrasluc/subscriptions","organizations_url":"https://api.github.com/users/rporrasluc/orgs","repos_url":"https://api.github.com/users/rporrasluc/repos","events_url":"https://api.github.com/users/rporrasluc/events{/privacy}","received_events_url":"https://api.github.com/users/rporrasluc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-07-16T06:34:45Z","updated_at":"2016-02-16T21:38:26Z","closed_at":null,"body":"Good morning lads,\r\n\r\nI have been getting this error for a while in a production server.\r\n\r\n```\r\nruby-oci8-2.1.8/lib/oci8/cursor.rb:538→ __fetch\r\nruby-oci8-2.1.8/lib/oci8/cursor.rb:538→ fetch_one_row_as_array\r\nruby-oci8-2.1.8/lib/oci8/cursor.rb:154→ fetch\r\nactiverecord-oracle_enhanced-adapter-1.6.1/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:163→ fetch\r\nactiverecord-oracle_enhanced-adapter-1.6.1/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:53→ block in exec_query\r\nactiverecord-4.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:466→ block in log\r\nactivesupport-4.2.0/lib/active_support/notifications/instrumenter.rb:20→ instrument\r\nactiverecord-4.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:460→ log\r\nactiverecord-oracle_enhanced-adapter-1.6.1/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1348→ log\r\nactiverecord-oracle_enhanced-adapter-1.6.1/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:23→ exec_query\r\nactiverecord-oracle_enhanced-adapter-1.6.1/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1308→ select\r\nactiverecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:32→ select_all\r\nactiverecord-4.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:68→ block in select_all\r\nactiverecord-4.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:83→ cache_sql\r\nactiverecord-4.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:68→ select_all\r\nactiverecord-oracle_enhanced-adapter-1.6.1/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1050→ columns_without_cache\r\nactiverecord-oracle_enhanced-adapter-1.6.1/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1017→ columns\r\nactiverecord-4.2.0/lib/active_record/connection_adapters/schema_cache.rb:43→ columns\r\nactiverecord-4.2.0/lib/active_record/attributes.rb:91→ columns\r\nactiverecord-4.2.0/lib/active_record/attributes.rb:96→ columns_hash\r\nactiverecord-4.2.0/lib/active_record/relation/query_methods.rb:968→ block in create_binds\r\nactiverecord-4.2.0/lib/active_record/relation/query_methods.rb:965→ each\r\nactiverecord-4.2.0/lib/active_record/relation/query_methods.rb:965→ partition\r\nactiverecord-4.2.0/lib/active_record/relation/query_methods.rb:965→ create_binds\r\nactiverecord-4.2.0/lib/active_record/relation/query_methods.rb:952→ build_where\r\nactiverecord-4.2.0/lib/active_record/relation/query_methods.rb:584→ where!\r\nactiverecord-4.2.0/lib/active_record/relation/query_methods.rb:574→ where\r\n\r\nApplication code...\r\n\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:427→ block in make_lambda\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:163→ call\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:163→ block in halting\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:92→ call\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:92→ _run_callbacks\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:734→ _run_process_action_callbacks\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:81→ run_callbacks\r\nactionpack-4.2.0/lib/abstract_controller/callbacks.rb:19→ process_action\r\nactionpack-4.2.0/lib/action_controller/metal/rescue.rb:29→ process_action\r\nactionpack-4.2.0/lib/action_controller/metal/instrumentation.rb:31→ block in process_action\r\nactivesupport-4.2.0/lib/active_support/notifications.rb:164→ block in instrument\r\nactivesupport-4.2.0/lib/active_support/notifications/instrumenter.rb:20→ instrument\r\nactivesupport-4.2.0/lib/active_support/notifications.rb:164→ instrument\r\nactionpack-4.2.0/lib/action_controller/metal/instrumentation.rb:30→ process_action\r\nactionpack-4.2.0/lib/action_controller/metal/params_wrapper.rb:250→ process_action\r\nactiverecord-4.2.0/lib/active_record/railties/controller_runtime.rb:18→ process_action\r\nactionpack-4.2.0/lib/abstract_controller/base.rb:137→ process\r\nactionview-4.2.0/lib/action_view/rendering.rb:30→ process\r\nactionpack-4.2.0/lib/action_controller/metal.rb:195→ dispatch\r\nactionpack-4.2.0/lib/action_controller/metal/rack_delegation.rb:13→ dispatch\r\nactionpack-4.2.0/lib/action_controller/metal.rb:236→ block in action\r\nactionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:73→ call\r\nactionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:73→ dispatch\r\nactionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:42→ serve\r\nactionpack-4.2.0/lib/action_dispatch/journey/router.rb:43→ block in serve\r\nactionpack-4.2.0/lib/action_dispatch/journey/router.rb:30→ each\r\nactionpack-4.2.0/lib/action_dispatch/journey/router.rb:30→ serve\r\nactionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:802→ call\r\nrailties-4.2.0/lib/rails/engine.rb:518→ call\r\nrailties-4.2.0/lib/rails/railtie.rb:194→ public_send\r\nrailties-4.2.0/lib/rails/railtie.rb:194→ method_missing\r\nactionpack-4.2.0/lib/action_dispatch/routing/mapper.rb:51→ serve\r\nactionpack-4.2.0/lib/action_dispatch/journey/router.rb:43→ block in serve\r\nactionpack-4.2.0/lib/action_dispatch/journey/router.rb:30→ each\r\nactionpack-4.2.0/lib/action_dispatch/journey/router.rb:30→ serve\r\nactionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:802→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/rack/agent_hooks.rb:30→ traced_call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/rack/browser_monitoring.rb:32→ traced_call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nrack-1.6.4/lib/rack/etag.rb:24→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nrack-1.6.4/lib/rack/conditionalget.rb:25→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nrack-1.6.4/lib/rack/head.rb:13→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactionpack-4.2.0/lib/action_dispatch/middleware/params_parser.rb:27→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactionpack-4.2.0/lib/action_dispatch/middleware/flash.rb:260→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nrack-1.6.4/lib/rack/session/abstract/id.rb:225→ context\r\nrack-1.6.4/lib/rack/session/abstract/id.rb:220→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactionpack-4.2.0/lib/action_dispatch/middleware/cookies.rb:560→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactiverecord-4.2.0/lib/active_record/query_cache.rb:36→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactiverecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:647→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactionpack-4.2.0/lib/action_dispatch/middleware/callbacks.rb:29→ block in call\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:88→ call\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:88→ _run_callbacks\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:734→ _run_call_callbacks\r\nactivesupport-4.2.0/lib/active_support/callbacks.rb:81→ run_callbacks\r\nactionpack-4.2.0/lib/action_dispatch/middleware/callbacks.rb:27→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactionpack-4.2.0/lib/action_dispatch/middleware/remote_ip.rb:78→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactionpack-4.2.0/lib/action_dispatch/middleware/debug_exceptions.rb:17→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactionpack-4.2.0/lib/action_dispatch/middleware/show_exceptions.rb:30→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nrailties-4.2.0/lib/rails/rack/logger.rb:38→ call_app\r\nrailties-4.2.0/lib/rails/rack/logger.rb:20→ block in call\r\nactivesupport-4.2.0/lib/active_support/tagged_logging.rb:68→ block in tagged\r\nactivesupport-4.2.0/lib/active_support/tagged_logging.rb:26→ tagged\r\nactivesupport-4.2.0/lib/active_support/tagged_logging.rb:68→ tagged\r\nrailties-4.2.0/lib/rails/rack/logger.rb:20→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nactionpack-4.2.0/lib/action_dispatch/middleware/request_id.rb:21→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nrack-1.6.4/lib/rack/methodoverride.rb:22→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nrack-1.6.4/lib/rack/runtime.rb:18→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nrack-1.6.4/lib/rack/sendfile.rb:113→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nrailties-4.2.0/lib/rails/engine.rb:518→ call\r\nrailties-4.2.0/lib/rails/application.rb:164→ call\r\nnewrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67→ call\r\nunicorn-4.9.0/lib/unicorn/http_server.rb:580→ process_client\r\nunicorn-4.9.0/lib/unicorn/http_server.rb:674→ worker_loop\r\nunicorn-4.9.0/lib/unicorn/http_server.rb:529→ spawn_missing_workers\r\nunicorn-4.9.0/lib/unicorn/http_server.rb:540→ maintain_worker_count\r\nunicorn-4.9.0/lib/unicorn/http_server.rb:294→ join\r\nunicorn-4.9.0/bin/unicorn:126→ <top (required)>\r\n/usr/local/bin/unicorn:23→ load\r\n/usr/local/bin/unicorn:23→ <main>\r\n```\r\n\r\nCould anyone please provide some feedback or have some idea of the origin of the issue?\r\n\r\nWe are using Unicorn, Rails 4.2 and activerecord-oracle_enhanced-adapter 1.6.0.\r\n\r\nVery much appreciated."},"comment":{"url":"https://api.github.com/repos/kubo/ruby-oci8/issues/comments/184884274","html_url":"https://github.com/kubo/ruby-oci8/issues/86#issuecomment-184884274","issue_url":"https://api.github.com/repos/kubo/ruby-oci8/issues/86","id":184884274,"user":{"login":"awaltman","id":10551290,"avatar_url":"https://avatars.githubusercontent.com/u/10551290?v=3","gravatar_id":"","url":"https://api.github.com/users/awaltman","html_url":"https://github.com/awaltman","followers_url":"https://api.github.com/users/awaltman/followers","following_url":"https://api.github.com/users/awaltman/following{/other_user}","gists_url":"https://api.github.com/users/awaltman/gists{/gist_id}","starred_url":"https://api.github.com/users/awaltman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awaltman/subscriptions","organizations_url":"https://api.github.com/users/awaltman/orgs","repos_url":"https://api.github.com/users/awaltman/repos","events_url":"https://api.github.com/users/awaltman/events{/privacy}","received_events_url":"https://api.github.com/users/awaltman/received_events","type":"User","site_admin":false},"created_at":"2016-02-16T21:38:26Z","updated_at":"2016-02-16T21:38:26Z","body":"I am seeing a similar problem in an application that has multiple threads. In my case the OCIBreak is created by ruby-oci8 when a thread executing a query is told to run by another thread. This is easily reproduced with:\r\n\r\n```ruby\r\nconn = OCI8.new($dbuser, $dbpass, $dbname)\r\nth = Thread.start do\r\n  begin\r\n    sleep 30\r\n    puts 'here'\r\n    conn.exec(\"BEGIN DBMS_LOCK.SLEEP(30); END;\")\r\n  rescue OCIBreak\r\n    puts 'OCIBreak'\r\n  end\r\nend\r\nsleep 1\r\nth.run\r\nsleep 1\r\nth.run\r\n```\r\nThis results in:\r\n```\r\nhere\r\nOCIBreak\r\n```\r\nThe same thing happens if the Thread.wakeup method is used instead.\r\n\r\nIt appears that this caused because the function `rb_threadptr_interrupt` is called by the function `rb_threadptr_ready` in Ruby's thread.c.\r\n\r\nTo workaround this problem I've changed our code to no longer call Thread.run/wakeup, but this has a slightly undesirable side effect because elsewhere in the thread it sleeps and I'd like to be able to have another thread interrupt the sleep. Now the first thread only resumes once the sleep completes.\r\n\r\nI noticed also that the ruby-pg folks reverted their use of a UBF to cancel queries because there were problems using it with signal handlers. See: https://groups.google.com/forum/#!topic/ruby-pg/5_ylGmog1S4\r\n\r\nThis can also be reproduced with ruby-oci8:\r\n\r\n```ruby\r\nconn = OCI8.new($dbuser, $dbpass, $dbname)\r\nsignal_received = false\r\ntrap 'USR1' do\r\n  puts 'got USR1'\r\n  signal_received = true\r\nend\r\nth = Thread.start do\r\n  sleep 5\r\n  Process.kill(\"USR1\", Process.pid)\r\nend\r\nbegin\r\n  conn.exec(\"BEGIN DBMS_LOCK.SLEEP(30); END;\")\r\nrescue OCIBreak\r\n  puts 'OCIBreak'\r\nend\r\n```\r\nWhich results in:\r\n```\r\ngot USR1\r\nOCIBreak\r\n```\r\nBoth problems happen using either Ruby 2.2 or 2.3.\r\n\r\nHopefully this helps to diagnose the problem for others!\r\n"}}