diff options
Diffstat (limited to 'lib/gitlab/import_export/fast_hash_serializer.rb')
-rw-r--r-- | lib/gitlab/import_export/fast_hash_serializer.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/gitlab/import_export/fast_hash_serializer.rb b/lib/gitlab/import_export/fast_hash_serializer.rb index 5a067b5c9f3..c6ecf13ded8 100644 --- a/lib/gitlab/import_export/fast_hash_serializer.rb +++ b/lib/gitlab/import_export/fast_hash_serializer.rb @@ -136,6 +136,12 @@ module Gitlab data = [] record.in_batches(of: @batch_size) do |batch| # rubocop:disable Cop/InBatches + # order each batch by it's primary key to ensure + # consistent and predictable ordering of each exported relation + # as additional `WHERE` clauses can impact the order in which data is being + # returned by database when no `ORDER` is specified + batch = batch.reorder(batch.klass.primary_key) + if Feature.enabled?(:export_fast_serialize_with_raw_json, default_enabled: true) data.append(JSONBatchRelation.new(batch, options, preloads[key]).tap(&:raw_json)) else |