mperham/sidekiq — pull request #744 by bcantin (2013-02-28 22:29:28+00:00)
Title: Not properly requeuing jobs when using a namespace

When I am using a namespace and I have jobs that are stopped via the command line, the jobs are not properly rpushed back to the correct queue.

When I am not using a namespace, the jobs are properly pushed to the correct queue.

When I use a namespace, 'snuffy' and investigate the key names in redis (using redis = Redis.new) before I send the stop command, I can see a list named "snuffy:default" as well as the current jobs running ("snuffy:default:blahblah:started")

When I send a stop command and investigate the key names I see a list named "snuffy:snuffy:queue:default", as well as a "snuffy:queue:default" list. The "snuffy:queue:default" contained all the jobs that were not processed yet, and the "snuffy:snuffy:queue:default" list contained the jobs that should have been pushed to the proper queue list.

When I do not use a namespace, I only see a "queue:default" list after I send the stop command. This list contains the jobs that were not processed as well as the jobs that were in flight.

I investigated the Sidekiq library and found the fetch.rb file that has the bulk_requeue method and the UnitOfWork Struct. When I logged the queue that was being put into the conn.rpush command, it was 'snuffy:queue:default'. When not using a namespace, it was "queue:default"

In this pull request there is a new test file called test_fetch_with_namespace that has the namespace being added to the Sidekiq.options hash.

There is also the code in lib/sidekiq/fetch that helps the new tests pass.