Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
088bd77d
Commit
088bd77d
authored
Mar 15, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename use_replica to use_replica_if_possible
Issue
https://gitlab.com/gitlab-org/gitlab/-/issues/322133
parent
3f079524
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
4 deletions
+3
-4
app/models/application_record.rb
app/models/application_record.rb
+1
-1
ee/lib/gitlab/database/load_balancing/connection_proxy.rb
ee/lib/gitlab/database/load_balancing/connection_proxy.rb
+0
-1
ee/lib/gitlab/database/load_balancing/session.rb
ee/lib/gitlab/database/load_balancing/session.rb
+2
-2
No files found.
app/models/application_record.rb
View file @
088bd77d
...
...
@@ -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"
)
...
...
ee/lib/gitlab/database/load_balancing/connection_proxy.rb
View file @
088bd77d
...
...
@@ -18,7 +18,6 @@ module Gitlab
delete
delete_all
insert
transaction
update
update_all
)
.
freeze
...
...
ee/lib/gitlab/database/load_balancing/session.rb
View file @
088bd77d
...
...
@@ -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!
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment