Skip to content

Add Advanced Search timeout

Dmitry Gruzd requested to merge 338836-add-advanced-search-timeout into master

What does this MR do and why?

This MR enables the timeout feature for Advanced Search. It was introduced to Basic Search in !65085 (merged).

Screenshots or screen recordings

Screenshot_2021-11-10_at_16.42.47

How to set up and validate locally

Option 1

Since it's pretty hard to cause timeouts in a local elasticsearch cluster I used a tool called Charles. You might need to find an alternative if you're on Linux.

  1. Enable Advanced Search in GDK if it's not configured
  2. Set up the proxy tool to capture and rewrite responses from Elasticsearch and replace "timed_out": false with "timed_out": true. I've replaced the entire response for requests that matched gitlab-development-issues/doc/_search?from=0&size=20&timeout=30s with
    {"hits": {"hits": [], "total": {"relation": "gte", "value": 0}, "max_score": null}, "took": 40, "timed_out": true}
  3. Point your gitlab installation to this proxy tool URL. For example:
    bin/rails runner "ApplicationSetting.current.update!(elasticsearch_url: 'http://localhost:54827')"
  4. Perform issues search
  5. Ensure that this page has the Your search timed out message
Easier option

As a much simpler, but less precise option you can do this:

  1. Enable Advanced Search in GDK if it's not configured
  2. Temporarily add this code to SearchController#show
    diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
    index ff52d76527e..e675fcac0cc 100644
    --- a/app/controllers/search_controller.rb
    +++ b/app/controllers/search_controller.rb
    @@ -27,6 +27,7 @@ class SearchController < ApplicationController
       urgency :high, [:opensearch]
    
       def show
    +    raise Elastic::TimeoutError
         @project = search_service.project
         @group = search_service.group
    
  3. Perform issues search
  4. Ensure that this page has the Your search timed out message

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #338836 (closed)

Edited by Dmitry Gruzd

Merge request reports

Loading