gaffneyc / sunspot-queue

Background search indexing using existing worker systems
MIT License
35 stars 37 forks source link

sunspot-queue is not threadsafe #22

Open travisp opened 9 years ago

travisp commented 9 years ago

Sidekiq uses threads to handle multiple workers, and the without_proxy helper is not threadsafe because it modifies Sunspot.session. The Sunspot::Queue::Sidekiq job workers can be modified to work safely like this:

    def perform(klass, id)
      object = constantize(klass).find(id)
      base_session = Sunspot.session.session
      base_session.index(object)
    end