Commit 9045a83f authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'bvl-deduplication-ff' into 'master'

Add a feature flag to disable deduplication

See merge request gitlab-org/gitlab!32469
parents bd002aac 5b0861be
...@@ -150,6 +150,24 @@ execute. ...@@ -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 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. 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 ## Job urgency
Jobs can have an `urgency` attribute set, which can be `:high`, Jobs can have an `urgency` attribute set, which can be `:high`,
......
...@@ -67,7 +67,7 @@ module Gitlab ...@@ -67,7 +67,7 @@ module Gitlab
end end
def droppable? def droppable?
idempotent? && duplicate? idempotent? && duplicate? && ::Feature.disabled?("disable_#{queue_name}_deduplication")
end end
private private
......
...@@ -113,22 +113,27 @@ describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gitlab_r ...@@ -113,22 +113,27 @@ describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gitlab_r
end end
describe 'droppable?' do describe 'droppable?' do
where(:idempotent, :duplicate) do where(:idempotent, :duplicate, :prevent_deduplication) do
# [true, false].repeated_permutation(2) # [true, false].repeated_permutation(3)
[[true, true], [[true, true, true],
[true, false], [true, true, false],
[false, true], [true, false, true],
[false, false]] [true, false, false],
[false, true, true],
[false, true, false],
[false, false, true],
[false, false, false]]
end end
with_them do with_them do
before do before do
allow(AuthorizedProjectsWorker).to receive(:idempotent?).and_return(idempotent) allow(AuthorizedProjectsWorker).to receive(:idempotent?).and_return(idempotent)
allow(duplicate_job).to receive(:duplicate?).and_return(duplicate) allow(duplicate_job).to receive(:duplicate?).and_return(duplicate)
stub_feature_flags("disable_#{queue}_deduplication" => prevent_deduplication)
end end
it 'is droppable when all conditions are met' do it 'is droppable when all conditions are met' do
if idempotent && duplicate if idempotent && duplicate && !prevent_deduplication
expect(duplicate_job).to be_droppable expect(duplicate_job).to be_droppable
else else
expect(duplicate_job).not_to be_droppable 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