-
Notifications
You must be signed in to change notification settings - Fork 388
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
Rails 4.2 with a JNDI connection breaks with use of ActiveRecord in config/initializers/*.rb #649
Comments
Full Tomcat log file:
|
Pull request 650 added to fix this problem (In master) |
Tracked down the issue down further, but not sure how to solve this one It does not apply to rails 4.1, but does to 4.2 module JndiConnectionPoolCallbacks
def self.prepare(adapter, connection)
if adapter.is_a?(ConnectionPoolCallbacks) && connection.jndi?
adapter.extend self # extend JndiConnectionPoolCallbacks
connection.disconnect! # disconnect initial (JNDI) connection if any
end
end
def on_checkin
disconnect!
end
def on_checkout
reconnect!
end
end The disconnect! works well, as long as you don't need to perform any ActiveRecord operations in your config/initializers Rails 4.1 does something like this:
Rails 4.2 does something like this
A workaround can performed by adding this to an initializer if you want to use ActiveRecord in your initializers module ActiveRecord::ConnectionAdapters
module Jdbc
# JNDI specific connection pool callbacks that make sure the JNDI connection
# is disconnected on check-in and looked up (re-connected) on-checkout.
module JndiConnectionPoolCallbacks
def self.prepare(adapter, connection)
if adapter.is_a?(ConnectionPoolCallbacks) && connection.jndi?
adapter.extend self # extend JndiConnectionPoolCallbacks
end
end
end
end
end Changing the issue name to more accurately reflect the problem |
The workaround listed above will consume a connection from the connection pool This connection is not released appropriately. |
…alize` ... which is probably for the best, but for the record this is due to changes in AR 4.2 as we now (postgresql adapter) follow code and eagerly load the type map (in initialize) this presents itself to be problematic as we disconnect! the initial connection while we still expect to execute statements as part of (PostgresqlAdapter's) initialize resolves #649
as noted at #620 (comment) ... 4679495 + a work-around due rails/rails#20516 should resolve this, thanks |
NOTE The nature of this has been isolated, and rather than being a JNDI regression in the 1.3 stable line, is a change in the expectations of Rails initializations in 4.2 and the way it interacts with JNDI. An appropriate solution and/or test suite is not available yet.
This MAY not be an issue with the activerecord-jdbc*-adapter, but
JNDI is now failing for the ActiveRecord 4.2 rails support (1.3.16)
This was NOT failing in the same tomcat server and setup for 4.1 rails (1.3.16) -
conf/server.xml, /META-INF/context.xml and /WEB-INF/web.xml are identical, and work with rails 4.1.10 and do not for the 4.2.1 version of rails
It produces this error (Full tomcat log attached as a file)
from the Exception
Relevant database.yaml is as follows
I have tested against master as well with
I'm going to continue trying to isolate this problem, and see If I can produce a test to diagnose it or fix it outright.
The text was updated successfully, but these errors were encountered: