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
a54f8b68
Commit
a54f8b68
authored
May 19, 2021
by
Nikola Milojevic
Committed by
Kamil Trzciński
May 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SidekiqClientMiddleware should continue using primary if primary was already selected
parent
cd011d38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
ee/lib/gitlab/database/load_balancing/sidekiq_client_middleware.rb
...tlab/database/load_balancing/sidekiq_client_middleware.rb
+1
-1
ee/spec/lib/gitlab/database/load_balancing/sidekiq_client_middleware_spec.rb
...database/load_balancing/sidekiq_client_middleware_spec.rb
+4
-4
No files found.
ee/lib/gitlab/database/load_balancing/sidekiq_client_middleware.rb
View file @
a54f8b68
...
...
@@ -26,7 +26,7 @@ module Gitlab
return
if
worker_class
.
get_data_consistency
==
:always
if
Session
.
current
.
performed_write
?
if
Session
.
current
.
use_primary
?
job
[
'database_write_location'
]
=
load_balancer
.
primary_write_location
else
job
[
'database_replica_location'
]
=
load_balancer
.
host
.
database_replica_location
...
...
ee/spec/lib/gitlab/database/load_balancing/sidekiq_client_middleware_spec.rb
View file @
a54f8b68
...
...
@@ -55,7 +55,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
context
'when write was not performed'
do
before
do
allow
(
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
receive
(
:
performed_write
?
).
and_return
(
false
)
allow
(
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
receive
(
:
use_primary
?
).
and_return
(
false
)
end
it
'passes database_replica_location'
do
...
...
@@ -69,7 +69,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
context
'when write was performed'
do
before
do
allow
(
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
receive
(
:
performed_write
?
).
and_return
(
true
)
allow
(
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
receive
(
:
use_primary
?
).
and_return
(
true
)
end
it
'passes primary write location'
,
:aggregate_failures
do
...
...
@@ -83,9 +83,9 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
end
shared_examples_for
'database location was already provided'
do
|
provided_database_location
,
other_location
|
shared_examples_for
'does not set database location again'
do
|
write_performed
|
shared_examples_for
'does not set database location again'
do
|
use_primary
|
before
do
allow
(
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
receive
(
:
performed_write?
).
and_return
(
write_performed
)
allow
(
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
receive
(
:
use_primary?
).
and_return
(
use_primary
)
end
it
'does not set database locations again'
do
...
...
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