Skip to content

Commit

Permalink
Merge branch 'main' into fix/write-digest-on-middleware-call
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenrixon committed May 25, 2023
2 parents a51a067 + bc2637b commit 03d4e8e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions lib/sidekiq_unique_jobs/locksmith.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

#
Expand Down
2 changes: 1 addition & 1 deletion spec/sidekiq_unique_jobs/digests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spec/sidekiq_unique_jobs/locksmith_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/support/sidekiq_unique_jobs/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 03d4e8e

Please sign in to comment.