Commit 24318cae authored by Bob Van Landuyt's avatar Bob Van Landuyt

Increase the deduplication TTL for future jobs

With this, the expiry for the deduplication key will be the time the
job was scheduled in the future + the configured deduplication time
for the job.

This makes sure that we do not expire before the job has even started,
which could happen for jobs scheduled in the future that aren't picked
up immediately after they should have been.

Changelog: fixed
parent d257c85b
...@@ -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