Commit 74c35852 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Handle elastic:reindex_cluster unique violation

parent c22d662c
---
title: Gracefully handle gitlab:elastic:reindex_cluster unique index violation
merge_request: 43690
author:
type: fixed
...@@ -91,11 +91,7 @@ namespace :gitlab do ...@@ -91,11 +91,7 @@ namespace :gitlab do
desc "GitLab | Elasticsearch | Zero-downtime cluster reindexing" desc "GitLab | Elasticsearch | Zero-downtime cluster reindexing"
task reindex_cluster: :environment do task reindex_cluster: :environment do
Elastic::ReindexingTask.create! trigger_cluster_reindexing
ElasticClusterReindexingCronWorker.perform_async
puts "Reindexing job was successfully scheduled".color(:green)
end end
desc "GitLab | Elasticsearch | Clear indexing status" desc "GitLab | Elasticsearch | Clear indexing status"
...@@ -137,6 +133,16 @@ namespace :gitlab do ...@@ -137,6 +133,16 @@ namespace :gitlab do
count count
end end
def trigger_cluster_reindexing
Elastic::ReindexingTask.create!
ElasticClusterReindexingCronWorker.perform_async
puts 'Reindexing job was successfully scheduled'.color(:green)
rescue PG::UniqueViolation, ActiveRecord::RecordNotUnique
puts 'There is another task in progress. Please wait for it to finish.'.color(:red)
end
def display_unindexed(projects) def display_unindexed(projects)
arr = if projects.count < 500 || ENV['SHOW_ALL'] arr = if projects.count < 500 || ENV['SHOW_ALL']
projects projects
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment