Browse Source

Test stabilization: Increase read timeout of Elasticsearch index creation to avoid index_already_exists_exception because of retry.

Thorsten Eckel 6 years ago
parent
commit
132a88005f
1 changed files with 7 additions and 1 deletions
  1. 7 1
      lib/search_index_backend.rb

+ 7 - 1
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'),
       }