Ensure Reenqueuer workers are not deduplicated
What does this MR do?
In a strict sense, RegistryConsistencyWorker
(which leverages Reenqueuer
) is not idempotent, since a subsequent run may alter the system state. It meets criteria 1 and 2 below, but not the 3rd one (note, I modified the 3rd criteria in this MR to more accurately match the codebase.)
From https://gitlab.com/gitlab-org/gitlab/-/blob/v13.6.1-ee/rubocop/cop/scalability/idempotent_worker.rb:
Avoid adding not idempotent workers.
A worker is considered idempotent if:
- It can safely run multiple times with the same arguments
- The application side-effects are expected to happen once (or side-effects of a second run are not impactful)
- It can safely be skipped if another job with the same arguments is already running or is in the queue
If all the above is true, make sure to mark it as so by calling the
idempotent!
method in the worker scope.See https://github.com/mperham/sidekiq/wiki/Best-Practices#2-make-your-job-idempotent-and-transactional
This is generalizable to any worker that leverages Reenqueuer
(there are no others that do yet).
Resolves #284826 (closed)
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
-
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.