diff --git a/README.md b/README.md index a9f48acd1..990066e9b 100644 --- a/README.md +++ b/README.md @@ -45,11 +45,11 @@ Want to show me some ❤️ for the hard work I do on this gem? You can use the - [reschedule_failed](#reschedule_failed) - [rescheduled](#rescheduled) - [timeout](#timeout) - - [unlock_failed](#unlock_failed) - - [unlocked](#unlocked) - - [unknown_sidekiq_worker](#unknown_sidekiq_worker) - - [Show Locks](#show-locks) - - [Show Lock](#show-lock) + - [unlock_failed](#unlock_failed) + - [unlocked](#unlocked) + - [unknown_sidekiq_worker](#unknown_sidekiq_worker) + - [Show Locks](#show-locks) + - [Show Lock](#show-lock) - [Testing](#testing) - [Validating Worker Configuration](#validating-worker-configuration) - [Uniqueness](#uniqueness) @@ -545,23 +545,23 @@ For when a job was successfully rescheduled This is also mostly useful for reporting/metrics purposes. What this reflection does is signal that the job was configured to wait (`lock_timeout` was configured), but we couldn't retrieve a lock even though we waited for some time. -### unlock_failed +#### unlock_failed This means that the server middleware could not unlock your job and the lock is kept (potentially preventing subsequent jobs from being pushed or processed). -### unlocked +#### unlocked Also mostly useful for reporting purposes. The job was successfully unlocked. -### unknown_sidekiq_worker +#### unknown_sidekiq_worker The reason this happens is that the server couldn't find a valid sidekiq worker class. Most likely, that worker isn't intended to be processed by this sidekiq server instance. -#### Show Locks +### Show Locks ![Locks](assets/unique_digests_1.png) -#### Show Lock +### Show Lock ![Lock](assets/unique_digests_2.png) diff --git a/lib/sidekiq_unique_jobs/locksmith.rb b/lib/sidekiq_unique_jobs/locksmith.rb index 9c06969cd..dd9af6e2b 100644 --- a/lib/sidekiq_unique_jobs/locksmith.rb +++ b/lib/sidekiq_unique_jobs/locksmith.rb @@ -127,7 +127,10 @@ def unlock(conn = nil) # def unlock!(conn = nil) call_script(:unlock, key.to_a, argv, conn) do |unlocked_jid| - reflect(:debug, :unlocked, item, unlocked_jid) if unlocked_jid == job_id + if unlocked_jid == job_id + reflect(:debug, :unlocked, item, unlocked_jid) + reflect(:unlocked, item) + end unlocked_jid end @@ -312,7 +315,7 @@ def brpoplpush(conn, wait) # @api private # def rpoplpush(conn) - conn.rpoplpush(key.queued, key.primed) + conn.lmove(key.queued, key.primed, "RIGHT", "LEFT") end # diff --git a/spec/sidekiq_unique_jobs/digests_spec.rb b/spec/sidekiq_unique_jobs/digests_spec.rb index bd88ae542..8a6984835 100644 --- a/spec/sidekiq_unique_jobs/digests_spec.rb +++ b/spec/sidekiq_unique_jobs/digests_spec.rb @@ -129,7 +129,7 @@ it "deletes all matching digests" do expect(delete_by_pattern).to be_a(Integer) - expect(digests.entries).to match_array([]) # rubocop:todo RSpec/MatchArray + expect(digests.entries).to be_empty end it "logs performance info" do diff --git a/spec/sidekiq_unique_jobs/locksmith_spec.rb b/spec/sidekiq_unique_jobs/locksmith_spec.rb index 5f0477cb2..b7b050662 100644 --- a/spec/sidekiq_unique_jobs/locksmith_spec.rb +++ b/spec/sidekiq_unique_jobs/locksmith_spec.rb @@ -338,10 +338,10 @@ # expect(locksmith_two).not_to have_received(:reflect).with(:locked, item_two) # end - # it "reflects on unlocked" do - # locksmith_one.lock - # allow(locksmith_one).to receive(:reflect) - # locksmith_one.unlock - # expect(locksmith_one).to have_received(:reflect).with(:unlocked, item_one) - # end + it "reflects on unlocked" do + locksmith_one.lock + allow(locksmith_one).to receive(:reflect) + locksmith_one.unlock + expect(locksmith_one).to have_received(:reflect).with(:unlocked, item_one) + end end diff --git a/spec/support/sidekiq_unique_jobs/testing.rb b/spec/support/sidekiq_unique_jobs/testing.rb index 41c5c7221..19f3d0138 100644 --- a/spec/support/sidekiq_unique_jobs/testing.rb +++ b/spec/support/sidekiq_unique_jobs/testing.rb @@ -328,7 +328,7 @@ def rpop(key) end def rpoplpush(source, destination) - redis { |conn| conn.rpoplpush(source, destination) } + redis { |conn| conn.lmove(source, destination, "RIGHT", "LEFT") } end def blpop(*args)