Commit 5b0861be authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add a feature flag to disable deduplication

This adds a feature flag allowing us to stop the automatic
deduplication of queues.

This gives us a way out if we were to find bugs caused by
deduplicating idempotent jobs.
parent 80182767
......@@ -150,6 +150,24 @@ execute.
More [deduplication strategies have been suggested](https://gitlab.com/gitlab-com/gl-infra/scalability/issues/195). If you are implementing a worker that
could benefit from a different strategy, please comment in the issue.
If the automatic deduplication were to cause issues in certain
queues. This can be temporarily disabled by enabling a feature flag
named `disable_<queue name>_deduplication`. For example to disable
deduplication for the `AuthorizedProjectsWorker`, we would enable the
feature flag `disable_authorized_projects_deduplication`.
From chatops:
```shell
/chatops run feature set disable_authorized_projects_deduplication true
```
From the rails console:
```ruby
Feature.enable!(:disable_authorized_projects_deduplication)
```
## Job urgency
Jobs can have an `urgency` attribute set, which can be `:high`,
......
......@@ -67,7 +67,7 @@ module Gitlab
end
def droppable?
idempotent? && duplicate?
idempotent? && duplicate? && ::Feature.disabled?("disable_#{queue_name}_deduplication")
end
private
......
......@@ -113,22 +113,27 @@ describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gitlab_r
end
describe 'droppable?' do
where(:idempotent, :duplicate) do
# [true, false].repeated_permutation(2)
[[true, true],
[true, false],
[false, true],
[false, false]]
where(:idempotent, :duplicate, :prevent_deduplication) do
# [true, false].repeated_permutation(3)
[[true, true, true],
[true, true, false],
[true, false, true],
[true, false, false],
[false, true, true],
[false, true, false],
[false, false, true],
[false, false, false]]
end
with_them do
before do
allow(AuthorizedProjectsWorker).to receive(:idempotent?).and_return(idempotent)
allow(duplicate_job).to receive(:duplicate?).and_return(duplicate)
stub_feature_flags("disable_#{queue}_deduplication" => prevent_deduplication)
end
it 'is droppable when all conditions are met' do
if idempotent && duplicate
if idempotent && duplicate && !prevent_deduplication
expect(duplicate_job).to be_droppable
else
expect(duplicate_job).not_to be_droppable
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment