#111 ✓resolved
mayoral

ActiveRecord session store not creating new records with Thin 1.2.4 and Rails 2.2.2

Reported by mayoral | September 7th, 2009 @ 04:41 AM | in Future

When updated to Thin 1.2.4, session store stops creating new session records in the database in an app with Rails 2.2.2. If i revert to Thin 1.2.2 the app starts again to record sessions in the database.

Another app with almost the same code and Rails 2.3.4 seems not to be afected by this behaviour in Thin 1.2.4.

Comments and changes to this ticket

  • macournoyer

    macournoyer September 7th, 2009 @ 04:19 PM

    Is there any error in Rails log or thin.log ?

  • mayoral

    mayoral September 7th, 2009 @ 06:25 PM

    No errors either in thin.log or production.log. But with Thin 1.2.4 the log is like:

    Processing ArticlesController#show (for x.x.x.x at 2009-09-07 y:y:y) [GET]
    Parameters: {....}

    And changing to Thin 1.2.2 the log is like:

    Processing ArticlesController#show (for x.x.x.x at 2009-09-07 y:y:y) [GET]
    Session ID: cda912c9cda2b90cd2f6cb3045bd59ed Parameters: {....}

    For more details, my setup is an Apache 2.2.3 (with the latest patches on CentOS) + mod_proxy_balancer + thin.

  • macournoyer

    macournoyer September 10th, 2009 @ 10:19 AM

    • State changed from “new” to “open”

    I cannot reproduce, can you post your environment.rb or the where your configure the session store (don't forget to hide the secret key).

    Are you using Ruby 1.8.7?

    What changed in 1.2.4 is that Thin now uses Rails Rack base interface if available. Maybe that is causing the issue.

  • mayoral

    mayoral September 10th, 2009 @ 10:41 AM

    I'm using Ruby Enterprise Edition 1.8.6-20090610.

    In config/environment.rb I have the next related to sessions:

    config.action_controller.session = {

    :session_key => '_saeta_session',
    :secret      => [THE SECRET HERE]
    

    }

    config.action_controller.session_store = :active_record_store

    Now that you mention the use of Rack the problem is with Rails 2.2.2 (without rack). Rails 2.3.4 works properly.

  • macournoyer

    macournoyer September 10th, 2009 @ 10:53 AM

    Ah! 2.2.2 IS rack based, I guess it's broken or was not complete. I'll try to refine the logic to check when to use the Rack-base interface: http://github.com/macournoyer/thin/blob/66bd68c2faccad3e5d5b5de48e2...

  • macournoyer

    macournoyer October 7th, 2009 @ 08:41 PM

    Can you try w/ this patch and let me know if it fixes it?
    I tested w/ Rails 2.3.2 and it worked.

    diff --git a/lib/rack/adapter/rails.rb b/lib/rack/adapter/rails.rb
    index 8e5fd81..24c3c06 100644
    --- a/lib/rack/adapter/rails.rb
    +++ b/lib/rack/adapter/rails.rb
    @@ -32,9 +32,7 @@ module Rack
           end
           
           def rack_based?
    -        ActionController.const_defined?(:Dispatcher) &&
    -          (ActionController::Dispatcher.instance_methods.include?(:call) ||
    -           ActionController::Dispatcher.instance_methods.include?("call"))
    +        Rails::VERSION::MAJOR >= 2 && Rails::VERSION::MINOR >= 3 && Rails::VERSION::TINY >= 2
           end
           
           def load_application
    
  • mayoral

    mayoral October 8th, 2009 @ 03:25 AM

    Here is the result (we updated to ree 1.8.7-20090928 some days ago):

    /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/rack/adapter/rails.rb:38: warning: toplevel constant VERSION referenced by Rack::Adapter::Rails::VERSION
    >> Exiting!
    /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/rack/adapter/rails.rb:38:in `rack_based?': 1.8.7 is not a class/module (TypeError)
    from /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/rack/adapter/rails.rb:25:in `initialize'
    from /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/rack/adapter/loader.rb:36:in `new'
    from /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/rack/adapter/loader.rb:36:in `for'
    from /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/thin/controllers/controller.rb:163:in `load_adapter'
    from /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/thin/controllers/controller.rb:67:in `start'
    from /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/thin/runner.rb:174:in `send'
    from /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/thin/runner.rb:174:in `run_command'
    from /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/lib/thin/runner.rb:140:in `run!'
    from /opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/thin-1.2.4/bin/thin:6
    from /opt/ruby-enterprise-1.8.7-20090928/bin/thin:19:in `load'
    from /opt/ruby-enterprise-1.8.7-20090928/bin/thin:19
    
  • macournoyer

    macournoyer October 8th, 2009 @ 08:00 AM

    Oops, this one should work for real now:

    diff --git a/lib/rack/adapter/rails.rb b/lib/rack/adapter/rails.rb
    index 8e5fd81..24c3c06 100644
    --- a/lib/rack/adapter/rails.rb
    +++ b/lib/rack/adapter/rails.rb
    @@ -32,9 +32,7 @@ module Rack
           end
           
           def rack_based?
    -        ActionController.const_defined?(:Dispatcher) &&
    -          (ActionController::Dispatcher.instance_methods.include?(:call) ||
    -           ActionController::Dispatcher.instance_methods.include?("call"))
    +        ::Rails::VERSION::MAJOR >= 2 && ::Rails::VERSION::MINOR >= 3 && ::Rails::VERSION::TINY >= 2
           end
           
           def load_application
    
  • mayoral
  • macournoyer

    macournoyer October 13th, 2009 @ 10:26 PM

    • State changed from “open” to “resolved”

    (from [b16e72ff779d9c077d24462666d4a5487449627c]) Ensure Rack base API is used in Rails adapter only if version >= 2.3.2 [#111 state:resolved] http://github.com/macournoyer/thin/commit/b16e72ff779d9c077d2446266...

  • Alexander Staubo

    Alexander Staubo November 5th, 2009 @ 04:27 AM

    FYI, your patch uses "Rails::VERSION" instead of "::Rails::VERSION", so it still fails. The fix:


    diff --git a/lib/rack/adapter/rails.rb b/lib/rack/adapter/rails.rb
    index 24c3c06..921f047 100644
    --- a/lib/rack/adapter/rails.rb +++ b/lib/rack/adapter/rails.rb @@ -32,7 +32,7 @@ module Rack

    {mkd-extraction-b489890af20e13e3bb26e4912df38e66}
    • {mkd-extraction-7d2bb7c7d4ee9e67be6e4141654a7e0b}
    • {mkd-extraction-7029849e8035efdc582b7c9413f55c14}

      end

      def load_application

  • Alexander Staubo

    Alexander Staubo November 5th, 2009 @ 04:29 AM

    Lighthouse screwed up the formatting and there's no way to edit comments. Oh well:

    diff --git a/lib/rack/adapter/rails.rb b/lib/rack/adapter/rails.rb
    index 24c3c06..921f047 100644
    --- a/lib/rack/adapter/rails.rb
    +++ b/lib/rack/adapter/rails.rb
    @@ -32,7 +32,7 @@ module Rack
           end
           
           def rack_based?
    -        Rails::VERSION::MAJOR >= 2 && Rails::VERSION::MINOR >= 2 && Rails::VERSION::TINY >= 3
    +        ::Rails::VERSION::MAJOR >= 2 && ::Rails::VERSION::MINOR >= 2 && ::Rails::VERSION::TINY >= 3
           end
           
           def load_application
    
  • macournoyer

    macournoyer November 5th, 2009 @ 09:54 AM

    This should be fixed in version 1.2.5 deployed yesterday on gemcutter.org

  • Alexander Staubo

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Referenced by

Pages