Commit 088bd77d authored by Quang-Minh Nguyen's avatar Quang-Minh Nguyen

Rename use_replica to use_replica_if_possible

Issue https://gitlab.com/gitlab-org/gitlab/-/issues/322133
parent 3f079524
......@@ -53,7 +53,7 @@ class ApplicationRecord < ActiveRecord::Base
# 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
::Gitlab::Database::LoadBalancing::Session.current.use_replica do
::Gitlab::Database::LoadBalancing::Session.current.use_replica_if_possible do
transaction(requires_new: true) do
connection.exec_query("SET LOCAL statement_timeout = 5000")
......
......@@ -18,7 +18,6 @@ module Gitlab
delete
delete_all
insert
transaction
update
update_all
).freeze
......
......@@ -61,7 +61,7 @@ module Gitlab
# - If the queries are about to write
# - The current session already performed writes
# - It prefers to use primary, aka, use_primary or use_primary! were called
def use_replica(&blk)
def use_replica_if_possible(&blk)
return yield if use_primary? || performed_write?
begin
......@@ -74,7 +74,7 @@ module Gitlab
end
def use_replica?
@use_replica && !use_primary? && !performed_write?
@use_replica == true && !use_primary? && !performed_write?
end
def write!
......
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