kiqstand
kiqstand copied to clipboard
Gets rid of disconnecting sessions as that is going to happen anyway sin...
...ce the session is stored on Fiber-local variables. Adds a note about how to reuse connections.
[ref https://github.com/mongoid/mongoid-site/pull/236]
@jonhyman thanks for taking the time to fork and submit the pull request, we've merged it in our own fork and are using the Celluloid::Thread patch to keep the connections per thread around.
@durran could kiqstand include the functionality? Using it could be optional for those who understand the implications, we're already doing this in a less invasive way:
config/initializers/sidekiq.rb
Sidekiq.configure_server do |config|
config.server_middleware do |chain|
# NOTE: Uses Kiqstand fork to clear IdentityMap without disconnecting
# See: http://blog.appsignal.com/blog/2014/03/31/mongodb-mongoid-and-sideiq-connection-problems.html and https://github.com/mongoid/kiqstand/pull/10
chain.add Kiqstand::Middleware
end
end
module Celluloid
class Thread < ::Thread
include Project::Extensions::Celluloid::Thread
end
end
For JRuby, instead of the Celluloid patch, we're thinking of using the mongoid_connection_pool gem (https://github.com/cpuguy83/mongoid_connection_pool) from @cpuguy83. This gem takes care of the session issue.
If we use the connection pool gem, is it still required to clear the identity map separately in another Sidekiq middleware?