Skip to content

[PP-7623] Expose SidekiqUniqueJobs lock info#3923

Open
yndajas wants to merge 1 commit intomainfrom
sidekiq-info
Open

[PP-7623] Expose SidekiqUniqueJobs lock info#3923
yndajas wants to merge 1 commit intomainfrom
sidekiq-info

Conversation

@yndajas
Copy link
Member

@yndajas yndajas commented Mar 6, 2026

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

Example lock info (in the console):

{
  "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
}

@yndajas yndajas changed the title [PP-7623] Expose more SidekiqUniqueJobs info [PP-7623] Expose SidekiqUniqueJobs lodk info Mar 6, 2026
@yndajas yndajas changed the title [PP-7623] Expose SidekiqUniqueJobs lodk info [PP-7623] Expose SidekiqUniqueJobs lock info Mar 6, 2026
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
}
```
@yndajas yndajas marked this pull request as ready for review March 6, 2026 15:19
Copy link
Member

@brucebolt brucebolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great find, I hadn't noticed this config option before.

The documentation says "create an additional key for the lock with a json object containing information about the lock". Have we checked the Redis instance will have enough memory to store this additional information during times of high load?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants