From 77256c99b943a8af86a848d3ca815d7154245795 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 2 Sep 2019 17:32:54 +0200 Subject: [PATCH] Follow up for issue #2720 - makes Model.search_index_reload more robust - Sometimes elasticsearch takes longer as expected and will raise timeout in Zammad. --- app/models/concerns/has_search_index_backend.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/has_search_index_backend.rb b/app/models/concerns/has_search_index_backend.rb index b2e4c3b48..bdf583b53 100644 --- a/app/models/concerns/has_search_index_backend.rb +++ b/app/models/concerns/has_search_index_backend.rb @@ -128,11 +128,12 @@ reload search index with full data =end def search_index_reload - tolerance = 5 + tolerance = 10 tolerance_count = 0 ids = all.order(created_at: :desc).pluck(:id) ids.each do |item_id| - item = find(item_id) + item = find_by(id: item_id) + next if !item next if item.ignore_search_indexing?(:destroy) begin @@ -140,6 +141,7 @@ reload search index with full data rescue => e logger.error "Unable to send #{item.class}.find(#{item.id}).search_index_update_backend backend: #{e.inspect}" tolerance_count += 1 + sleep 15 raise "Unable to send #{item.class}.find(#{item.id}).search_index_update_backend backend: #{e.inspect}" if tolerance_count == tolerance end end