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
76920101
Commit
76920101
authored
Sep 30, 2019
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo: Invalidate cache after refreshing foreign tables
Invalidate cache after rake geo:db:refresh_foreign_tables
parent
d021195a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
7 deletions
+57
-7
changelogs/unreleased/14794-rake-gitlab-geo-check-does-not-give-the-actual-state.yml
...-rake-gitlab-geo-check-does-not-give-the-actual-state.yml
+5
-0
ee/lib/gitlab/geo.rb
ee/lib/gitlab/geo.rb
+7
-3
ee/lib/gitlab/geo/fdw.rb
ee/lib/gitlab/geo/fdw.rb
+10
-0
ee/lib/gitlab/geo/geo_tasks.rb
ee/lib/gitlab/geo/geo_tasks.rb
+2
-0
ee/spec/lib/gitlab/geo/fdw_spec.rb
ee/spec/lib/gitlab/geo/fdw_spec.rb
+8
-0
ee/spec/lib/gitlab/geo_spec.rb
ee/spec/lib/gitlab/geo_spec.rb
+25
-4
No files found.
changelogs/unreleased/14794-rake-gitlab-geo-check-does-not-give-the-actual-state.yml
0 → 100644
View file @
76920101
---
title
:
'
Geo:
Invalidate
cache
after
refreshing
foreign
tables'
merge_request
:
17885
author
:
type
:
fixed
ee/lib/gitlab/geo.rb
View file @
76920101
...
...
@@ -98,9 +98,13 @@ module Gitlab
end
def
self
.
expire_cache!
CACHE_KEYS
.
each
do
|
raw_key
|
l1_cache
.
expire
(
raw_key
)
l2_cache
.
expire
(
raw_key
)
expire_cache_keys!
(
CACHE_KEYS
)
end
def
self
.
expire_cache_keys!
(
keys
)
keys
.
each
do
|
key
|
l1_cache
.
expire
(
key
)
l2_cache
.
expire
(
key
)
end
true
...
...
ee/lib/gitlab/geo/fdw.rb
View file @
76920101
...
...
@@ -7,6 +7,12 @@ module Gitlab
FOREIGN_SERVER
=
'gitlab_secondary'
FOREIGN_SCHEMA
=
'gitlab_secondary'
CACHE_KEYS
=
%i(
geo_FOREIGN_SCHEMA_exist
geo_foreign_schema_tables_match
geo_fdw_count_tables
)
.
freeze
class
<<
self
# Return if FDW is enabled for this instance
#
...
...
@@ -54,6 +60,10 @@ module Gitlab
ActiveRecord
::
Schema
.
tables
.
reject
{
|
table
|
table
.
start_with?
(
'pg_'
)
}.
count
end
def
expire_cache!
Gitlab
::
Geo
.
expire_cache_keys!
(
CACHE_KEYS
)
end
private
def
fdw_capable?
...
...
ee/lib/gitlab/geo/geo_tasks.rb
View file @
76920101
...
...
@@ -49,6 +49,8 @@ module Gitlab
ActiveRecord
::
Base
.
connection
.
execute
(
sql
)
end
end
Gitlab
::
Geo
::
Fdw
.
expire_cache!
end
def
foreign_server_configured?
...
...
ee/spec/lib/gitlab/geo/fdw_spec.rb
View file @
76920101
...
...
@@ -152,6 +152,14 @@ describe Gitlab::Geo::Fdw, :geo do
end
end
describe
'.expire_cache!'
do
it
'calls Gitlab::Geo.expire_cache_keys!'
do
expect
(
Gitlab
::
Geo
).
to
receive
(
:expire_cache_keys!
).
with
(
Gitlab
::
Geo
::
Fdw
::
CACHE_KEYS
)
described_class
.
expire_cache!
end
end
def
with_foreign_connection
Geo
::
TrackingBase
.
connection
end
...
...
ee/spec/lib/gitlab/geo_spec.rb
View file @
76920101
...
...
@@ -160,14 +160,35 @@ describe Gitlab::Geo, :geo, :request_store do
describe
'.expire_cache!'
do
it
'clears the Geo cache keys'
,
:request_store
do
described_class
::
CACHE_KEYS
.
each
do
|
raw_
key
|
expanded_key
=
"geo:
#{
raw_key
}
:
#{
Gitlab
::
VERSION
}
:
#{
Rails
.
version
}
"
described_class
::
CACHE_KEYS
.
each
do
|
key
|
content
=
"
#{
key
}
-content
"
expect
(
Rails
.
cache
).
to
receive
(
:delete
).
with
(
expanded_key
).
and_call_original
expect
(
Gitlab
::
ThreadMemoryCache
.
cache_backend
).
to
receive
(
:delete
).
with
(
expanded_key
).
and_call_original
described_class
.
cache_value
(
key
)
{
content
}
expect
(
described_class
.
cache_value
(
key
)).
to
eq
(
content
)
end
described_class
.
expire_cache!
described_class
::
CACHE_KEYS
.
each
do
|
key
|
expect
(
described_class
.
cache_value
(
key
)
{
nil
}).
to
be_nil
end
end
end
describe
'.expire_cache_keys!'
do
it
'clears specified keys'
,
:request_store
do
cache_data
=
{
one:
1
,
two:
2
}
cache_data
.
each
do
|
key
,
value
|
described_class
.
cache_value
(
key
)
{
value
}
expect
(
described_class
.
cache_value
(
key
)).
to
eq
(
value
)
end
described_class
.
expire_cache_keys!
(
cache_data
.
keys
)
cache_data
.
keys
.
each
do
|
key
|
expect
(
described_class
.
cache_value
(
key
)
{
nil
}).
to
be_nil
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