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
70f7799e
Commit
70f7799e
authored
Apr 05, 2020
by
Mike Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo: Fix repository verification on the primary
And any future usage of `geo_uncached_queries` on the primary.
parent
8f81006a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
3 deletions
+64
-3
ee/changelogs/unreleased/mk-fix-primary-verification.yml
ee/changelogs/unreleased/mk-fix-primary-verification.yml
+5
-0
ee/lib/ee/gitlab/database.rb
ee/lib/ee/gitlab/database.rb
+5
-3
ee/spec/lib/ee/gitlab/database_spec.rb
ee/spec/lib/ee/gitlab/database_spec.rb
+54
-0
No files found.
ee/changelogs/unreleased/mk-fix-primary-verification.yml
0 → 100644
View file @
70f7799e
---
title
:
'
Geo:
Fix
repository
verification
on
the
primary'
merge_request
:
28893
author
:
type
:
fixed
ee/lib/ee/gitlab/database.rb
View file @
70f7799e
...
...
@@ -25,11 +25,13 @@ module EE
ActiveRecord
::
Base
.
establish_connection
(
config
)
end
def
geo_uncached_queries
def
geo_uncached_queries
(
&
block
)
raise
'No block given'
unless
block_given?
Geo
::
TrackingBase
.
uncached
do
ActiveRecord
::
Base
.
uncached
do
if
::
Gitlab
::
Geo
.
secondary?
Geo
::
TrackingBase
.
uncached
(
&
block
)
else
yield
end
end
...
...
ee/spec/lib/ee/gitlab/database_spec.rb
View file @
70f7799e
...
...
@@ -3,6 +3,8 @@
require
'spec_helper'
describe
Gitlab
::
Database
do
include
::
EE
::
GeoHelpers
describe
'.read_only?'
do
context
'with Geo enabled'
do
before
do
...
...
@@ -64,4 +66,56 @@ describe Gitlab::Database do
expect
(
config
[
'prepared_statements'
]).
to
eq
(
false
)
end
end
describe
'.geo_uncached_queries'
do
context
'when no block is given'
do
it
'raises error'
do
expect
do
described_class
.
geo_uncached_queries
end
.
to
raise_error
(
'No block given'
)
end
end
context
'when the current node is a primary'
do
let!
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
it
'wraps the block in an ActiveRecord::Base.uncached block'
do
stub_current_geo_node
(
primary
)
expect
(
Geo
::
TrackingBase
).
not_to
receive
(
:uncached
)
expect
(
ActiveRecord
::
Base
).
to
receive
(
:uncached
).
and_call_original
expect
do
|
b
|
described_class
.
geo_uncached_queries
(
&
b
)
end
.
to
yield_control
end
end
context
'when the current node is a secondary'
do
let!
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let!
(
:secondary
)
{
create
(
:geo_node
)
}
it
'wraps the block in a Geo::TrackingBase.uncached block and an ActiveRecord::Base.uncached block'
do
stub_current_geo_node
(
secondary
)
expect
(
Geo
::
TrackingBase
).
to
receive
(
:uncached
).
and_call_original
expect
(
ActiveRecord
::
Base
).
to
receive
(
:uncached
).
and_call_original
expect
do
|
b
|
described_class
.
geo_uncached_queries
(
&
b
)
end
.
to
yield_control
end
end
context
'when there is no current node'
do
it
'wraps the block in an ActiveRecord::Base.uncached block'
do
expect
(
Geo
::
TrackingBase
).
not_to
receive
(
:uncached
)
expect
(
ActiveRecord
::
Base
).
to
receive
(
:uncached
).
and_call_original
expect
do
|
b
|
described_class
.
geo_uncached_queries
(
&
b
)
end
.
to
yield_control
end
end
end
end
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