summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-02-08 08:51:29 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2018-02-08 09:44:58 +0100
commit7e00adcc71877677637a8ebe0680f1d38176e7c8 (patch)
tree003009d4b2d7769b194b424d7a69b8352d11d1d1
parent7e424eb852716495073881710e8a8851b4a4cd5a (diff)
downloadgitlab-ce-7e00adcc71877677637a8ebe0680f1d38176e7c8.tar.gz
Early migrations populating fork-networks: no-op
Since populating the fork networks was scheduled multiple times because of bugs that needed to be fixed: - https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15595/ Creating fork networks for projects that were missing the root of the fork network. - https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15709 The API allowed creating forked_project_links without fork_network_members. Scheduling this migration multiple times would case it to run concurrently. Which in turn would try to insert the same data into `fork_network_members` causing duplicate key errors. This avoids running the migration multiple times.
-rw-r--r--changelogs/unreleased/bvl-fix-concurrent-fork-network-migrations.yml5
-rw-r--r--db/migrate/20170929131201_populate_fork_networks.rb16
-rw-r--r--db/post_migrate/20171124150326_reschedule_fork_network_creation.rb16
3 files changed, 7 insertions, 30 deletions
diff --git a/changelogs/unreleased/bvl-fix-concurrent-fork-network-migrations.yml b/changelogs/unreleased/bvl-fix-concurrent-fork-network-migrations.yml
new file mode 100644
index 00000000000..b2a77f75e55
--- /dev/null
+++ b/changelogs/unreleased/bvl-fix-concurrent-fork-network-migrations.yml
@@ -0,0 +1,5 @@
+---
+title: Avoid running `PopulateForkNetworksRange`-migration multiple times
+merge_request: 16988
+author:
+type: fixed
diff --git a/db/migrate/20170929131201_populate_fork_networks.rb b/db/migrate/20170929131201_populate_fork_networks.rb
index 1214962770f..ddbf27e1852 100644
--- a/db/migrate/20170929131201_populate_fork_networks.rb
+++ b/db/migrate/20170929131201_populate_fork_networks.rb
@@ -6,22 +6,8 @@ class PopulateForkNetworks < ActiveRecord::Migration
DOWNTIME = false
- MIGRATION = 'PopulateForkNetworksRange'.freeze
- BATCH_SIZE = 100
- DELAY_INTERVAL = 15.seconds
-
- disable_ddl_transaction!
-
- class ForkedProjectLink < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'forked_project_links'
- end
-
def up
- say 'Populating the `fork_networks` based on existing `forked_project_links`'
-
- queue_background_migration_jobs_by_range_at_intervals(ForkedProjectLink, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE)
+ say 'Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller'
end
def down
diff --git a/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb b/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb
index 05430efe1f6..26f917d5a1e 100644
--- a/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb
+++ b/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb
@@ -3,22 +3,8 @@ class RescheduleForkNetworkCreation < ActiveRecord::Migration
DOWNTIME = false
- MIGRATION = 'PopulateForkNetworksRange'.freeze
- BATCH_SIZE = 100
- DELAY_INTERVAL = 15.seconds
-
- disable_ddl_transaction!
-
- class ForkedProjectLink < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'forked_project_links'
- end
-
def up
- say 'Populating the `fork_networks` based on existing `forked_project_links`'
-
- queue_background_migration_jobs_by_range_at_intervals(ForkedProjectLink, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE)
+ say 'Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller'
end
def down