Commit 3dfbfa4e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Adjust batch size for migrating runners token

parent 1143411a
...@@ -5,7 +5,7 @@ class ScheduleRunnersTokenEncryption < ActiveRecord::Migration ...@@ -5,7 +5,7 @@ class ScheduleRunnersTokenEncryption < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
BATCH_SIZE = 10000 BATCH_SIZE = 10000
RANGE_SIZE = 100 RANGE_SIZE = 2000
MIGRATION = 'EncryptRunnersTokens' MIGRATION = 'EncryptRunnersTokens'
MODELS = [ MODELS = [
...@@ -20,7 +20,7 @@ class ScheduleRunnersTokenEncryption < ActiveRecord::Migration ...@@ -20,7 +20,7 @@ class ScheduleRunnersTokenEncryption < ActiveRecord::Migration
def up def up
MODELS.each do |model| MODELS.each do |model|
model.each_batch(of: BATCH_SIZE) do |relation, index| model.each_batch(of: BATCH_SIZE) do |relation, index|
delay = index * 2.minutes delay = index * 4.minutes
relation.each_batch(of: RANGE_SIZE) do |relation| relation.each_batch(of: RANGE_SIZE) do |relation|
range = relation.pluck('MIN(id)', 'MAX(id)').first range = relation.pluck('MIN(id)', 'MAX(id)').first
......
...@@ -24,13 +24,13 @@ describe ScheduleRunnersTokenEncryption, :migration do ...@@ -24,13 +24,13 @@ describe ScheduleRunnersTokenEncryption, :migration do
Timecop.freeze do Timecop.freeze do
migrate! migrate!
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 'settings', 1, 1) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'settings', 1, 1)
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 'namespace', 11, 11) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'namespace', 11, 11)
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'namespace', 12, 12) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(8.minutes, 'namespace', 12, 12)
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 'project', 111, 111) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'project', 111, 111)
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'project', 114, 114) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(8.minutes, 'project', 114, 114)
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, 'runner', 201, 201) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'runner', 201, 201)
expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'runner', 202, 202) expect(described_class::MIGRATION).to be_scheduled_delayed_migration(8.minutes, 'runner', 202, 202)
expect(BackgroundMigrationWorker.jobs.size).to eq 7 expect(BackgroundMigrationWorker.jobs.size).to eq 7
end end
end end
......
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