From 6728ed6fe203d0613ee63c89a08a70fffb93405c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 8 Mar 2022 12:20:17 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- lib/gitlab/database.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/gitlab/database.rb') diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index 9b32d285ec0..950119e155e 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -195,6 +195,16 @@ module Gitlab MAX_TIMESTAMP_VALUE > timestamp ? timestamp : MAX_TIMESTAMP_VALUE.dup end + def self.all_uncached(&block) + # Calls to #uncached only disable caching for the current connection. Since the load balancer + # can potentially upgrade from read to read-write mode (using a different connection), we specify + # up-front that we'll explicitly use the primary for the duration of the operation. + Gitlab::Database::LoadBalancing::Session.current.use_primary do + base_models = database_base_models.values + base_models.reduce(block) { |blk, model| -> { model.uncached(&blk) } }.call + end + end + def self.allow_cross_joins_across_databases(url:) # this method is implemented in: # spec/support/database/prevent_cross_joins.rb -- cgit v1.2.3