Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.x query cache check accesses connection before app #2142

Closed
pritchie opened this issue Jul 19, 2011 · 7 comments
Closed

3.x query cache check accesses connection before app #2142

pritchie opened this issue Jul 19, 2011 · 7 comments

Comments

@pritchie
Copy link

The following code in 3.0.9 causes an error to be raised w/ mysql2 on connect before the controller is loaded.

module ActiveRecord
  class QueryCache
    def call(env)
      ActiveRecord::Base.cache do
        @app.call(env)
      end
    end
  end
end

3.1 has slightly different code but the same issue.

This means you can't rescue any AR connection errors from your controller.

Both are trying to access the AR connection which causes the mysql2 gem to try and connect to the DB. My app has a specific action that attempts to write to the DB but still needs to perform a redirect if the write fails.

It feels like simply setting @query_cache_enabled shouldn't require firing up the connection. I'm willing to work on a patch if someone can point me in the right direction.

@skippy
Copy link

skippy commented Jul 23, 2011

hey @pritchie ;) You aren't in PDX right now are you? If so, come on over to the hackfest and we can work on this one.

@skippy
Copy link

skippy commented Jul 23, 2011

sample app is here. The fix is a 2 liner but let me get some test cases in and then we'll see what the rails core folks have to say

skippy pushed a commit to skippy/rails that referenced this issue Jul 23, 2011
@arunagw
Copy link
Member

arunagw commented Dec 8, 2011

@pritchie Can you please confirm if this issue still exists ??

@pritchie
Copy link
Author

pritchie commented Dec 8, 2011

Yes, the issue still exists.

@steveklabnik
Copy link
Member

Does this happen on 3.2? Or just 3.1?

@pritchie
Copy link
Author

Not seeing this in 3.2! Thanks!

@steveklabnik
Copy link
Member

No, thank you for verifying! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants