summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 15:09:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 15:09:21 +0000
commitc36152ff8c41fad2f413f253eb7ac5c927e47c56 (patch)
treebbf300da207de3e8bbf272d44111ceedb18f5833 /lib/gitlab/import_export
parent286fe61013674fe2d245ffc8d2233baf09923e70 (diff)
downloadgitlab-ce-c36152ff8c41fad2f413f253eb7ac5c927e47c56.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/import_export')
-rw-r--r--lib/gitlab/import_export/fast_hash_serializer.rb6
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