Jruby Activerecord is giving me stale connections
I have a Jruby app that spins up several background Java threads that share an ActiveRecord (2.3.开发者_开发百科5) connection. If they sleep for some time and then try to do something database related, the first queries never execute. I believe this is because the connections are stale, but the code itself doesn't throw any errors.
I've tried doing a ActiveRecord::Base.connection.verify! but it still craps out. I'm using ActiveRecord jdbcmysql 0.9.7 but am now trying the newest 1.0.2 to see if that helps.
We had the exact problem, the solution is to call the line of code below at the end of the thread.
ActiveRecord::Base.clear_active_connections!
精彩评论