summaryrefslogtreecommitdiff
path: root/db/post_migrate
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-05 15:32:52 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-05 15:32:52 +0100
commit5f57c7a5a54d844fb3f8566dd81da3cdde2f3c5b (patch)
treedaff347a1fce0728cdb658464a48cc87e74662d2 /db/post_migrate
parent48b0bc330add0fbb3398890e20a7444ba69d5f9a (diff)
downloadgitlab-ce-5f57c7a5a54d844fb3f8566dd81da3cdde2f3c5b.tar.gz
Revert create job service because of load balancing
Currently we still need to run EnsureStageService within a transaction, because when it runs within in a transaction we are going to stick to the primary database when using database load balancing. Extracting this out of the transaction makes it possible to hit into problems with replication lag in pipeline commit status API, which can cause a lot of trouble.
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb19
-rw-r--r--db/post_migrate/20180125111139_add_unique_pipeline_stage_name_index.rb17
2 files changed, 15 insertions, 21 deletions
diff --git a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
index 89ed422ea1c..be5a80261c0 100644
--- a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
+++ b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
@@ -4,6 +4,21 @@ class RemoveRedundantPipelineStages < ActiveRecord::Migration
DOWNTIME = false
def up
+ remove_concurrent_index :ci_stages, [:pipeline_id, :name]
+
+ remove_redundant_pipeline_stages!
+
+ add_concurrent_index :ci_stages, [:pipeline_id, :name], unique: true
+ end
+
+ def down
+ remove_concurrent_index :ci_stages, [:pipeline_id, :name], unique: true
+ add_concurrent_index :ci_stages, [:pipeline_id, :name]
+ end
+
+ private
+
+ def remove_redundant_pipeline_stages!
redundant_stages_ids = <<~SQL
SELECT id FROM ci_stages WHERE (pipeline_id, name) IN (
SELECT pipeline_id, name FROM ci_stages
@@ -27,8 +42,4 @@ class RemoveRedundantPipelineStages < ActiveRecord::Migration
SQL
end
end
-
- def down
- # noop
- end
end
diff --git a/db/post_migrate/20180125111139_add_unique_pipeline_stage_name_index.rb b/db/post_migrate/20180125111139_add_unique_pipeline_stage_name_index.rb
deleted file mode 100644
index 4fa148b2446..00000000000
--- a/db/post_migrate/20180125111139_add_unique_pipeline_stage_name_index.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-class AddUniquePipelineStageNameIndex < ActiveRecord::Migration
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- disable_ddl_transaction!
-
- def up
- remove_concurrent_index :ci_stages, [:pipeline_id, :name]
- add_concurrent_index :ci_stages, [:pipeline_id, :name], unique: true
- end
-
- def down
- remove_concurrent_index :ci_stages, [:pipeline_id, :name], unique: true
- add_concurrent_index :ci_stages, [:pipeline_id, :name]
- end
-end