From: Pete Brumm on 16 Apr 2010 15:59 Artūras Šlajus wrote: > Chuck Remes wrote: >> Look up #release_connection in >> ActiveRecord::ConnectionAdapters::ConnectionPool. It does exactly what >> you need whereas that call to #clear_reloadable_connections! might be >> doing unnecessary work. > Unfortunately that doesn't work :) > > EventMachine.defer( > proc do > SingletonBlock.started(name) > LOGGER.block(name) { operation.call } > end, > proc do > LOGGER.block("#{name} CALLBACK") { callback.call } if > callback > SingletonBlock.finished(name) > ActiveRecord::Base.connection_pool.release_connection > #ActiveRecord::Base.clear_reloadable_connections! > end > ) > > Still hangs :) using ActiveRecord::Base.connection_pool.release_connection with jruby and with delayed_jobs running in same jvm I was seeing hanging on long running methods with lots of queries. I changed my invoke_job to the following and no more lockups def invoke_job begin payload_object.perform ensure ActiveRecord::Base.connection_pool.release_connection end end Active Record's connection pool uses the thread_id to checkout connections. if event machine is switching threads as it sees fit than this probably won't work. you may have to rework the connection pool to allow a better checkout checkin process. -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: [QUIZ] Console-based Pixel Editor (#231) Next: Ruby Midwest Conference Speakers & BBQ! |