summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-01-04 16:49:15 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2018-01-05 16:23:25 +0100
commit7f30bb9c29bc1ff0c903a16bbf678db31c7408ec (patch)
tree2937b82739b7abda61d39fbdfd64a7c39847f8aa /spec/migrations
parent0788b37fba26ab7113ff4a580d3fb92c926299b7 (diff)
downloadgitlab-ce-7f30bb9c29bc1ff0c903a16bbf678db31c7408ec.tar.gz
Run background migrations with a minimum intervaldelay-background-migrations
This adds a minimum interval to BackgroundMigrationWorker, ensuring background migrations of the same class only run once every 5 minutes. This prevents a thundering herd problem where scheduled migrations all run at once due to their delays having been expired (e.g. as the result of a queue being paused for a long time). If a job was recently executed it's rescheduled with a delay that equals the remaining time of the job's lease. This means that if the lease expires in two minutes we only need to wait two minutes, instead of five. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/41624
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/normalize_ldap_extern_uids_spec.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/spec/migrations/normalize_ldap_extern_uids_spec.rb b/spec/migrations/normalize_ldap_extern_uids_spec.rb
index 262d7742aaf..56a78f52802 100644
--- a/spec/migrations/normalize_ldap_extern_uids_spec.rb
+++ b/spec/migrations/normalize_ldap_extern_uids_spec.rb
@@ -27,11 +27,11 @@ describe NormalizeLdapExternUids, :migration, :sidekiq do
migrate!
expect(BackgroundMigrationWorker.jobs[0]['args']).to eq([described_class::MIGRATION, [1, 2]])
- expect(BackgroundMigrationWorker.jobs[0]['at']).to eq(10.seconds.from_now.to_f)
+ expect(BackgroundMigrationWorker.jobs[0]['at']).to eq(5.minutes.from_now.to_f)
expect(BackgroundMigrationWorker.jobs[1]['args']).to eq([described_class::MIGRATION, [3, 4]])
- expect(BackgroundMigrationWorker.jobs[1]['at']).to eq(20.seconds.from_now.to_f)
+ expect(BackgroundMigrationWorker.jobs[1]['at']).to eq(10.minutes.from_now.to_f)
expect(BackgroundMigrationWorker.jobs[2]['args']).to eq([described_class::MIGRATION, [5, 5]])
- expect(BackgroundMigrationWorker.jobs[2]['at']).to eq(30.seconds.from_now.to_f)
+ expect(BackgroundMigrationWorker.jobs[2]['at']).to eq(15.minutes.from_now.to_f)
expect(BackgroundMigrationWorker.jobs.size).to eq 3
end
end