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
b36051f4
Commit
b36051f4
authored
Feb 02, 2021
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added fallback code to database load balancer to with Standby clusters
parent
752745ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
ee/lib/gitlab/database/load_balancing/load_balancer.rb
ee/lib/gitlab/database/load_balancing/load_balancer.rb
+2
-0
ee/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb
.../lib/gitlab/database/load_balancing/load_balancer_spec.rb
+9
-0
lib/gitlab/database.rb
lib/gitlab/database.rb
+12
-0
No files found.
ee/lib/gitlab/database/load_balancing/load_balancer.rb
View file @
b36051f4
...
...
@@ -135,6 +135,8 @@ module Gitlab
def
primary_write_location
location
=
read_write
do
|
connection
|
::
Gitlab
::
Database
.
get_write_location
(
connection
)
rescue
ActiveRecord
::
StatementInvalid
::
Gitlab
::
Database
.
get_replay_write_location
(
connection
)
end
return
location
if
location
...
...
ee/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb
View file @
b36051f4
...
...
@@ -255,6 +255,15 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do
expect
{
lb
.
primary_write_location
}.
to
raise_error
(
RuntimeError
)
end
it
'fallbacks to #get_replay_write_location when #get_write_location raises error'
do
connection
=
double
(
:connection
)
allow
(
lb
).
to
receive
(
:read_write
).
and_yield
(
connection
)
allow
(
::
Gitlab
::
Database
).
to
receive
(
:get_write_location
).
and_raise
(
ActiveRecord
::
StatementInvalid
)
expect
(
::
Gitlab
::
Database
).
to
receive
(
:get_replay_write_location
).
and_return
(
'0/C73A0D88'
)
lb
.
primary_write_location
end
end
describe
'#all_caught_up?'
do
...
...
lib/gitlab/database.rb
View file @
b36051f4
...
...
@@ -256,6 +256,8 @@ module Gitlab
row
[
'system_identifier'
]
end
# @param [ActiveRecord::Connection] ar_connection
# @return [String]
def
self
.
get_write_location
(
ar_connection
)
row
=
ar_connection
.
select_all
(
"SELECT pg_current_wal_insert_lsn()::text AS location"
)
...
...
@@ -264,6 +266,16 @@ module Gitlab
row
[
'location'
]
if
row
end
# @param [ActiveRecord::Connection] ar_connection
# @return [String]
def
self
.
get_replay_write_location
(
ar_connection
)
row
=
ar_connection
.
select_all
(
"SELECT pg_last_wal_replay_lsn()::text AS location"
)
.
first
row
[
'location'
]
if
row
end
private_class_method
:database_version
def
self
.
add_post_migrate_path_to_rails
(
force:
false
)
...
...
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