Skip to content
Snippets Groups Projects
Commit dbe8193e authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
Browse files

Merge branch 'mk/fix-batcher-if-more-source-records-than-destination-records' into 'master'

Geo: Fix registry backfilling

See merge request !87720
parents 83839672 b3ee8ce8
No related branches found
No related tags found
2 merge requests!96059Draft: Add GraphQL query for deployment details,!87720Geo: Fix registry backfilling
Pipeline #617381681 passed
......@@ -47,12 +47,11 @@ def get_batch_last_id(batch_first_id)
source_class_last_id, more_records = get_source_batch_last_id(batch_first_id)
destination_class_last_id, more_destination_records = get_destination_batch_last_id(batch_first_id)
batch_last_id =
if !more_records && more_destination_records
destination_class_last_id
else
source_class_last_id
end
batch_last_id = if source_class_last_id && destination_class_last_id
[source_class_last_id, destination_class_last_id].max
else
source_class_last_id || destination_class_last_id
end
if more_records || more_destination_records
increment_batch(batch_last_id)
......@@ -116,7 +115,7 @@ def get_destination_batch_last_id(batch_first_id)
EXISTS (
SELECT #{source_foreign_key}
FROM #{destination_class.table_name}
WHERE #{source_foreign_key} >= MAX(batch.#{source_foreign_key})
WHERE #{source_foreign_key} > MAX(batch.#{source_foreign_key})
) AS more_rows
FROM (
SELECT #{source_foreign_key}
......
......@@ -44,7 +44,9 @@
described_class.new(destination_class, key: key, batch_size: destination_class.count).next_range!
end
it { is_expected.to be_nil }
it 'starts from the beginning' do
expect(subject).to eq(1..destination_records.second.public_send(source_foreign_key))
end
end
context 'when the previous batch did not include the end of the table' do
......@@ -155,7 +157,9 @@
described_class.new(destination_class, key: key, batch_size: batch_size).next_range!
end
it { is_expected.to be_nil }
it 'starts from the beginning' do
expect(subject).to eq(1..orphaned_destination_foreign_key_id)
end
context 'if cache is cleared' do
it 'starts from the beginning' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment