Commit 98fa61ef authored by James Fargher's avatar James Fargher

Merge branch 'bvl-search-count-optimizations' into 'master'

Decrease the default fast statement timeout

See merge request gitlab-org/gitlab!81270
parents e3142872 bb9480ad
......@@ -25,6 +25,7 @@ class SearchController < ApplicationController
feature_category :global_search
urgency :high, [:opensearch]
urgency :low, [:count]
def show
@project = search_service.project
......
......@@ -60,8 +60,10 @@ class ApplicationRecord < ActiveRecord::Base
end
# Start a new transaction with a shorter-than-usual statement timeout. This is
# currently one third of the default 15-second timeout
def self.with_fast_read_statement_timeout(timeout_ms = 5000)
# currently one third of the default 15-second timeout with a 500ms buffer
# to allow callers gracefully handling the errors to still complete within
# the 5s target duration of a low urgency request.
def self.with_fast_read_statement_timeout(timeout_ms = 4500)
::Gitlab::Database::LoadBalancing::Session.current.fallback_to_replicas_for_ambiguous_queries do
transaction(requires_new: true) do # rubocop:disable Performance/ActiveRecordSubtransactions
connection.exec_query("SET LOCAL statement_timeout = #{timeout_ms}")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment