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
e6358d2d
Commit
e6358d2d
authored
Dec 12, 2017
by
Brett Walker
Committed by
Nick Thomas
Dec 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Geo: cache results in issue and message count being incorrect"
parent
4897eecb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
6 deletions
+54
-6
app/services/base_count_service.rb
app/services/base_count_service.rb
+2
-0
changelogs/unreleased-ee/4070-geo-caching-issue-count.yml
changelogs/unreleased-ee/4070-geo-caching-issue-count.yml
+5
-0
ee/app/services/ee/base_count_service.rb
ee/app/services/ee/base_count_service.rb
+13
-0
spec/ee/spec/services/base_count_service_spec.rb
spec/ee/spec/services/base_count_service_spec.rb
+30
-0
spec/services/users/keys_count_service_spec.rb
spec/services/users/keys_count_service_spec.rb
+4
-6
No files found.
app/services/base_count_service.rb
View file @
e6358d2d
# Base class for services that count a single resource such as the number of
# Base class for services that count a single resource such as the number of
# issues for a project.
# issues for a project.
class
BaseCountService
class
BaseCountService
prepend
::
EE
::
BaseCountService
def
relation_for_count
def
relation_for_count
raise
(
raise
(
NotImplementedError
,
NotImplementedError
,
...
...
changelogs/unreleased-ee/4070-geo-caching-issue-count.yml
0 → 100644
View file @
e6358d2d
---
title
:
Issue count now refreshes quicker on geo secondary
merge_request
:
3639
author
:
type
:
fixed
ee/app/services/ee/base_count_service.rb
0 → 100644
View file @
e6358d2d
module
EE
module
BaseCountService
# geo secondary cache should expire quicker than primary, otherwise various counts
# could be incorrect for 2 weeks.
def
cache_options
raise
NotImplementedError
.
new
unless
defined?
(
super
)
value
=
super
value
[
:expires_in
]
=
20
.
minutes
if
::
Gitlab
::
Geo
.
secondary?
value
end
end
end
spec/ee/spec/services/base_count_service_spec.rb
0 → 100644
View file @
e6358d2d
require
'spec_helper'
describe
BaseCountService
do
include
::
EE
::
GeoHelpers
describe
'#cache_options'
do
subject
{
described_class
.
new
.
cache_options
}
it
'returns the default'
do
stub_current_geo_node
(
nil
)
is_expected
.
to
include
(
:raw
)
is_expected
.
not_to
include
(
:expires_in
)
end
it
'returns default on a Geo primary'
do
stub_current_geo_node
(
create
(
:geo_node
,
:primary
))
is_expected
.
to
include
(
:raw
)
is_expected
.
not_to
include
(
:expires_in
)
end
it
'returns cache of 20 mins on a Geo secondary'
do
stub_current_geo_node
(
create
(
:geo_node
))
is_expected
.
to
include
(
:raw
)
is_expected
.
to
include
(
expires_in:
20
.
minutes
)
end
end
end
spec/services/users/keys_count_service_spec.rb
View file @
e6358d2d
...
@@ -15,14 +15,12 @@ describe Users::KeysCountService, :use_clean_rails_memory_store_caching do
...
@@ -15,14 +15,12 @@ describe Users::KeysCountService, :use_clean_rails_memory_store_caching do
expect
(
service
.
count
).
to
eq
(
1
)
expect
(
service
.
count
).
to
eq
(
1
)
end
end
it
'caches the number of keys in Redis'
do
it
'caches the number of keys in Redis'
,
:request_store
do
service
.
delete_cache
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
service
.
count
}.
count
service
.
delete_cache
service
.
delete_cache
recorder
=
ActiveRecord
::
QueryRecorder
.
new
do
expect
{
2
.
times
{
service
.
count
}
}.
not_to
exceed_query_limit
(
control_count
)
2
.
times
{
service
.
count
}
end
expect
(
recorder
.
count
).
to
eq
(
1
)
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