From 132a88005ffabc40bee4935209897fb1c293c935 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Sat, 7 Jul 2018 11:11:16 +0200 Subject: [PATCH] Test stabilization: Increase read timeout of Elasticsearch index creation to avoid index_already_exists_exception because of retry. --- lib/search_index_backend.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb index d97ebe783..7b791147e 100644 --- a/lib/search_index_backend.rb +++ b/lib/search_index_backend.rb @@ -165,13 +165,19 @@ create/update/delete index Rails.logger.info "# curl -X PUT \"#{url}\" \\" Rails.logger.debug { "-d '#{data[:data].to_json}'" } + # note that we use a high read timeout here because + # otherwise the request will be retried (underhand) + # which leads to an "index_already_exists_exception" + # HTTP 400 status error + # see: https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts/issues/8 + # Improving the Elasticsearch config is probably the proper solution response = UserAgent.put( url, data[:data], { json: true, open_timeout: 8, - read_timeout: 12, + read_timeout: 30, user: Setting.get('es_user'), password: Setting.get('es_password'), }