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
1387e6bf
Commit
1387e6bf
authored
May 24, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move LB Consistency to Core
parent
5b15b1b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
36 deletions
+6
-36
ee/lib/ee/gitlab/database/consistency.rb
ee/lib/ee/gitlab/database/consistency.rb
+0
-20
lib/gitlab/database/consistency.rb
lib/gitlab/database/consistency.rb
+5
-15
scripts/rspec_helpers.sh
scripts/rspec_helpers.sh
+1
-1
spec/lib/gitlab/database/consistency_spec.rb
spec/lib/gitlab/database/consistency_spec.rb
+0
-0
No files found.
ee/lib/ee/gitlab/database/consistency.rb
deleted
100644 → 0
View file @
5b15b1b7
# frozen_string_literal: true
module
EE
module
Gitlab
module
Database
module
Consistency
extend
::
Gitlab
::
Utils
::
Override
##
# In EE we are disabling the database load balancing for calls that
# require read consistency after recent writes.
#
override
:with_read_consistency
def
with_read_consistency
(
&
block
)
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_primary
(
&
block
)
end
end
end
end
end
lib/gitlab/database/consistency.rb
View file @
1387e6bf
...
@@ -4,28 +4,18 @@ module Gitlab
...
@@ -4,28 +4,18 @@ module Gitlab
module
Database
module
Database
##
##
# This class is used to make it possible to ensure read consistency in
# This class is used to make it possible to ensure read consistency in
# GitLab
EE
without the need of overriding a lot of methods / classes /
# GitLab without the need of overriding a lot of methods / classes /
# classs.
# classs.
#
#
# This is a CE class that does nothing in CE, because database load
# balancing is EE-only feature, but you can still use it in CE. It will
# start ensuring read consistency once it is overridden in EE.
#
# Using this class in CE helps to avoid creeping discrepancy between CE /
# EE only to force usage of the primary database in EE.
#
class
Consistency
class
Consistency
##
##
# In CE there is no database load balancing, so all reads are expected to
# Within the block, disable the database load balancing for calls that
# be consistent by the ACID guarantees of a single PostgreSQL instance.
# require read consistency after recent writes.
#
# This method is overridden in EE.
#
#
def
self
.
with_read_consistency
(
&
block
)
def
self
.
with_read_consistency
(
&
block
)
yield
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_primary
(
&
block
)
end
end
end
end
end
end
end
end
::
Gitlab
::
Database
::
Consistency
.
singleton_class
.
prepend_mod_with
(
'Gitlab::Database::Consistency'
)
scripts/rspec_helpers.sh
View file @
1387e6bf
...
@@ -85,7 +85,7 @@ function rspec_db_library_code() {
...
@@ -85,7 +85,7 @@ function rspec_db_library_code() {
local
db_files
=
"spec/lib/gitlab/database/ spec/support/helpers/database/"
local
db_files
=
"spec/lib/gitlab/database/ spec/support/helpers/database/"
if
[[
-d
"ee/"
]]
;
then
if
[[
-d
"ee/"
]]
;
then
db_files
=
"
${
db_files
}
ee/spec/lib/
gitlab/database/ ee/spec/lib/
ee/gitlab/database_spec.rb"
db_files
=
"
${
db_files
}
ee/spec/lib/ee/gitlab/database_spec.rb"
fi
fi
rspec_simple_job
"--
${
db_files
}
"
rspec_simple_job
"--
${
db_files
}
"
...
...
ee/
spec/lib/gitlab/database/consistency_spec.rb
→
spec/lib/gitlab/database/consistency_spec.rb
View file @
1387e6bf
File moved
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