Commit 63f58200 authored by Patrick Bair's avatar Patrick Bair

Merge branch 'mc/backstage/delete-background-jobs' into 'master'

Implement method for deleting remaining jobs

See merge request gitlab-org/gitlab!51827
parents c6a6f3bb 7d6bcdfc
......@@ -33,7 +33,7 @@ module Gitlab
next unless job.queue == self.queue
next unless migration_class == steal_class
next if block_given? && !(yield migration_args)
next if block_given? && !(yield job)
begin
perform(migration_class, migration_args) if job.delete
......
......@@ -164,8 +164,8 @@ module Gitlab
"this could indicate the previous partitioning migration has been rolled back."
end
Gitlab::BackgroundMigration.steal(MIGRATION_CLASS_NAME) do |raw_arguments|
JobArguments.from_array(raw_arguments).source_table_name == table_name.to_s
Gitlab::BackgroundMigration.steal(MIGRATION_CLASS_NAME) do |background_job|
JobArguments.from_array(background_job.args.second).source_table_name == table_name.to_s
end
primary_key = connection.primary_key(table_name)
......
......@@ -55,7 +55,7 @@ RSpec.describe Gitlab::BackgroundMigration do
expect(described_class).to receive(:perform)
.with('Foo', [10, 20])
described_class.steal('Foo') { |(arg1, arg2)| arg1 == 10 && arg2 == 20 }
described_class.steal('Foo') { |job| job.args.second.first == 10 && job.args.second.second == 20 }
end
it 'does not steal jobs that do not match the predicate' do
......
......@@ -513,6 +513,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::TableManagementHe
context 'finishing pending background migration jobs' do
let(:source_table_double) { double('table name') }
let(:raw_arguments) { [1, 50_000, source_table_double, partitioned_table, source_column] }
let(:background_job) { double('background job', args: ['background jobs', raw_arguments]) }
before do
allow(migration).to receive(:table_exists?).with(partitioned_table).and_return(true)
......@@ -528,7 +529,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::TableManagementHe
expect(Gitlab::BackgroundMigration).to receive(:steal)
.with(described_class::MIGRATION_CLASS_NAME)
.and_yield(raw_arguments)
.and_yield(background_job)
expect(source_table_double).to receive(:==).with(source_table.to_s)
......
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