ruby-oci8 and connection reuse

Discussion in 'Ruby/Rails' started by zellster, Aug 23, 2009.

  1. zellster

    zellster New Member

    Configuration:

    LiteSpeed Std for Linux v3.3.24
    LSAPI v3.5
    Ruby v1.8.6
    Rails v1.2.6
    ruby-oci8 v1.0.6

    After configuring my Rails application to work with LiteSpeed, connecting to the site results in the following exception:

    RuntimeError (The connection cannot be reused in the forked process.):
    /usr/local/lib/site_ruby/1.8/oci8.rb:683:in `initialize'
    /usr/local/lib/site_ruby/1.8/oci8.rb:247:in `new'
    /usr/local/lib/site_ruby/1.8/oci8.rb:247:in `exec'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/oracle_adapter.rb:629:in `ping'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/oracle_adapter.rb:198:in `active?'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/abstract_adapter.rb:93:in `verify!'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:109:in `verify_active_connections!'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:108:in `each_value'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:108:in `verify_active_connections!'
    /usr/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:110:in `prepare_application'
    /usr/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/dispatcher.rb:39:in `dispatch'
    /opt/lsws/fcgi-bin/RailsRunner.rb:32

    The error goes away if I comment out the following line in RailsRunner.rb:

    #ActiveRecord::Base.connection.disconnect! and @reconnect = true if defined?(ActiveRecord::Base)

    Is this due to the older version of Rails I am running, or something else to do with Oracle? The only docs I could find about this issue is from here:

    http://groups.google.com/group/phusion-passenger/browse_thread/thread/b00d4770bc1d00b8
  2. mistwang

    mistwang LiteSpeed Staff

    The DB connection must be closed after Rails application initialization bofore forking children process to serve requests.

    Works for MySQL, may have issue with oracle, so you may need to close it explicitly at the end of initialization code of your app.

Share This Page