From 3198604bacd8b6051210dfa6bd089f131e92b216 Mon Sep 17 00:00:00 2001 From: Ynda Jas Date: Thu, 5 Mar 2026 17:22:40 +0000 Subject: [PATCH] Expose SidekiqUniqueJobs lock info We occasionally have issues with publishing where we're unable to acquire a lock for a job via SidekiqUniqueJobs. We'd like to make it easier to understand what locks are currently in place This adds extra information to the locks created by SidekiqUniqueJobs and available via a Rails console or in the Sidekiq web UI. This includes the lock args: values that determine a job's uniqueness, which vary by job (see the individual job classes for their definitions) but generally include a base path or a content ID Accessing the lock info requires a digest, which is a hashed value generated by SidekiqUniqueJobs I think based on the payload. This digest and the lock args are visible together in the logs as the `message` https://github.com/mhenrixon/sidekiq-unique-jobs/blob/f67f34642bc9e85aeb999bf08fe0a5ef0aa6a12a/lib/sidekiq_unique_jobs/lock_digest.rb#L53-L61 To access the lock info via the console: ```rb digest = "uniquejobs:c83a5ff5da097c8a8bb2ae9034373327" SidekiqUniqueJobs::Lock.new(digest).info.value ``` To access the lock info via the Sidekiq web UI (in this example with a deployed instance port-forwarded to localhost:8080): http://localhost:8080/sidekiq/locks/uniquejobs:c83a5ff5da097c8a8bb2ae9034373327 Example lock info (in the console): ```rb { "worker" => "DownstreamDraftJob", "queue" => "downstream_low", "limit" => nil, "timeout" => 0, "ttl" => 3600, "type" => "until_executing", "lock_args" => [ "c6c6c598-31e6-472c-9266-fd6e559e6377", "en", false, [], "DownstreamDraftJob" ], "time" => 1772740352.249766, "at" => nil } ``` --- config/initializers/sidekiq.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index da1354b063..4243500687 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,6 +1,7 @@ SidekiqUniqueJobs.configure do |config| config.enabled = !Rails.env.test? # SidekiqUniqueJobs recommends not testing this behaviour https://github.com/mhenrixon/sidekiq-unique-jobs#uniqueness config.lock_ttl = 1.hour.to_i + config.lock_info = true end Sidekiq.configure_client do |config|