Follow up for issue #2720 - makes Model.search_index_reload more robust - Sometimes elasticsearch takes longer as expected and will raise timeout in Zammad.

This commit is contained in:
Martin Edenhofer 2019-09-02 17:32:54 +02:00 committed by Thorsten Eckel
parent c88739cde8
commit 77256c99b9

View file

@ -128,11 +128,12 @@ reload search index with full data
=end =end
def search_index_reload def search_index_reload
tolerance = 5 tolerance = 10
tolerance_count = 0 tolerance_count = 0
ids = all.order(created_at: :desc).pluck(:id) ids = all.order(created_at: :desc).pluck(:id)
ids.each do |item_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) next if item.ignore_search_indexing?(:destroy)
begin begin
@ -140,6 +141,7 @@ reload search index with full data
rescue => e rescue => e
logger.error "Unable to send #{item.class}.find(#{item.id}).search_index_update_backend backend: #{e.inspect}" logger.error "Unable to send #{item.class}.find(#{item.id}).search_index_update_backend backend: #{e.inspect}"
tolerance_count += 1 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 raise "Unable to send #{item.class}.find(#{item.id}).search_index_update_backend backend: #{e.inspect}" if tolerance_count == tolerance
end end
end end