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
3f079524
Commit
3f079524
authored
Mar 12, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force with_fast_statement_timeout to use replicas
parent
e1b019bf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
app/models/application_record.rb
app/models/application_record.rb
+6
-4
lib/gitlab/issuables_count_for_state.rb
lib/gitlab/issuables_count_for_state.rb
+1
-1
No files found.
app/models/application_record.rb
View file @
3f079524
...
...
@@ -52,13 +52,15 @@ 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_statement_timeout
def
self
.
with_fast_read_statement_timeout
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_replica
do
transaction
(
requires_new:
true
)
do
connection
.
exec_query
(
"SET LOCAL statement_timeout = 5000"
)
yield
end
end
end
def
self
.
safe_find_or_create_by
(
*
args
,
&
block
)
safe_ensure_unique
(
retries:
1
)
do
...
...
lib/gitlab/issuables_count_for_state.rb
View file @
3f079524
...
...
@@ -78,7 +78,7 @@ module Gitlab
# to perform the calculation more efficiently. Until then, use a shorter
# timeout and return -1 as a sentinel value if it is triggered
begin
ApplicationRecord
.
with_fast_statement_timeout
do
ApplicationRecord
.
with_fast_
read_
statement_timeout
do
finder
.
count_by_state
end
rescue
ActiveRecord
::
QueryCanceled
=>
err
...
...
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