Commit d15efc8e authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'bvl-fix-deduplication-in-future' into 'master'

Increase the deduplication TTL for future jobs

See merge request gitlab-org/gitlab!73257
parents 0e40d773 24318cae
...@@ -54,9 +54,12 @@ module Gitlab ...@@ -54,9 +54,12 @@ module Gitlab
strong_memoize(:expiry) do strong_memoize(:expiry) do
next duplicate_job.duplicate_key_ttl unless duplicate_job.scheduled? next duplicate_job.duplicate_key_ttl unless duplicate_job.scheduled?
time_diff = duplicate_job.scheduled_at.to_i - Time.now.to_i time_diff = [
duplicate_job.scheduled_at.to_i - Time.now.to_i,
0
].max
time_diff > 0 ? time_diff : duplicate_job.duplicate_key_ttl time_diff + duplicate_job.duplicate_key_ttl
end end
end end
end end
......
...@@ -85,7 +85,7 @@ RSpec.shared_examples 'deduplicating jobs when scheduling' do |strategy_name| ...@@ -85,7 +85,7 @@ RSpec.shared_examples 'deduplicating jobs when scheduling' do |strategy_name|
allow(fake_duplicate_job).to receive(:scheduled_at).and_return(Time.now + time_diff) allow(fake_duplicate_job).to receive(:scheduled_at).and_return(Time.now + time_diff)
allow(fake_duplicate_job).to receive(:options).and_return({ including_scheduled: true }) allow(fake_duplicate_job).to receive(:options).and_return({ including_scheduled: true })
allow(fake_duplicate_job).to( allow(fake_duplicate_job).to(
receive(:check!).with(time_diff.to_i).and_return('the jid')) receive(:check!).with(time_diff.to_i + fake_duplicate_job.duplicate_key_ttl).and_return('the jid'))
allow(fake_duplicate_job).to receive(:idempotent?).and_return(true) allow(fake_duplicate_job).to receive(:idempotent?).and_return(true)
allow(fake_duplicate_job).to receive(:update_latest_wal_location!) allow(fake_duplicate_job).to receive(:update_latest_wal_location!)
allow(fake_duplicate_job).to receive(:set_deduplicated_flag!) allow(fake_duplicate_job).to receive(:set_deduplicated_flag!)
......
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