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
ce3cd71e
Commit
ce3cd71e
authored
Mar 10, 2021
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix RuboCop offenses for Lint/HashCompareByIdentity
parent
e1822027
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
.rubocop_manual_todo.yml
.rubocop_manual_todo.yml
+0
-4
ee/lib/gitlab/database/load_balancing/load_balancer.rb
ee/lib/gitlab/database/load_balancing/load_balancer.rb
+7
-7
No files found.
.rubocop_manual_todo.yml
View file @
ce3cd71e
...
@@ -2518,7 +2518,3 @@ Style/ClassEqualityComparison:
...
@@ -2518,7 +2518,3 @@ Style/ClassEqualityComparison:
Exclude
:
Exclude
:
-
spec/lib/peek/views/active_record_spec.rb
-
spec/lib/peek/views/active_record_spec.rb
-
ee/spec/lib/peek/views/active_record_spec.rb
-
ee/spec/lib/peek/views/active_record_spec.rb
Lint/HashCompareByIdentity
:
Exclude
:
-
ee/lib/gitlab/database/load_balancing/load_balancer.rb
ee/lib/gitlab/database/load_balancing/load_balancer.rb
View file @
ce3cd71e
...
@@ -18,7 +18,7 @@ module Gitlab
...
@@ -18,7 +18,7 @@ module Gitlab
# hosts - The hostnames/addresses of the additional databases.
# hosts - The hostnames/addresses of the additional databases.
def
initialize
(
hosts
=
[])
def
initialize
(
hosts
=
[])
@host_list
=
HostList
.
new
(
hosts
.
map
{
|
addr
|
Host
.
new
(
addr
,
self
)
})
@host_list
=
HostList
.
new
(
hosts
.
map
{
|
addr
|
Host
.
new
(
addr
,
self
)
})
@connection_db_roles
=
{}
@connection_db_roles
=
{}
.
compare_by_identity
end
end
# Yields a connection that can be used for reads.
# Yields a connection that can be used for reads.
...
@@ -34,11 +34,11 @@ module Gitlab
...
@@ -34,11 +34,11 @@ module Gitlab
begin
begin
connection
=
host
.
connection
connection
=
host
.
connection
@connection_db_roles
[
connection
.
object_id
]
=
ROLE_REPLICA
@connection_db_roles
[
connection
]
=
ROLE_REPLICA
return
yield
connection
return
yield
connection
rescue
=>
error
rescue
=>
error
@connection_db_roles
.
delete
(
connection
.
object_id
)
if
connection
.
present?
@connection_db_roles
.
delete
(
connection
)
if
connection
.
present?
if
serialization_failure?
(
error
)
if
serialization_failure?
(
error
)
# This error can occur when a query conflicts. See
# This error can occur when a query conflicts. See
...
@@ -83,7 +83,7 @@ module Gitlab
...
@@ -83,7 +83,7 @@ module Gitlab
read_write
(
&
block
)
read_write
(
&
block
)
ensure
ensure
@connection_db_roles
.
delete
(
connection
.
object_id
)
if
connection
.
present?
@connection_db_roles
.
delete
(
connection
)
if
connection
.
present?
end
end
# Yields a connection that can be used for both reads and writes.
# Yields a connection that can be used for both reads and writes.
...
@@ -94,19 +94,19 @@ module Gitlab
...
@@ -94,19 +94,19 @@ module Gitlab
# a few times.
# a few times.
retry_with_backoff
do
retry_with_backoff
do
connection
=
ActiveRecord
::
Base
.
retrieve_connection
connection
=
ActiveRecord
::
Base
.
retrieve_connection
@connection_db_roles
[
connection
.
object_id
]
=
ROLE_PRIMARY
@connection_db_roles
[
connection
]
=
ROLE_PRIMARY
yield
connection
yield
connection
end
end
ensure
ensure
@connection_db_roles
.
delete
(
connection
.
object_id
)
if
connection
.
present?
@connection_db_roles
.
delete
(
connection
)
if
connection
.
present?
end
end
# Recognize the role (primary/replica) of the database this connection
# Recognize the role (primary/replica) of the database this connection
# is connecting to. If the connection is not issued by this load
# is connecting to. If the connection is not issued by this load
# balancer, return nil
# balancer, return nil
def
db_role_for_connection
(
connection
)
def
db_role_for_connection
(
connection
)
@connection_db_roles
[
connection
.
object_id
]
@connection_db_roles
[
connection
]
end
end
# Returns a host to use for queries.
# Returns a host to use for queries.
...
...
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