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
c947b6d5
Commit
c947b6d5
authored
Apr 17, 2020
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix ES indexed namespaces stale cache bug"
This reverts commit
bcf42d85
.
parent
87a600de
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
28 deletions
+10
-28
ee/app/models/elasticsearch_indexed_namespace.rb
ee/app/models/elasticsearch_indexed_namespace.rb
+0
-5
ee/changelogs/unreleased/213777-fix-stale-cache-bug.yml
ee/changelogs/unreleased/213777-fix-stale-cache-bug.yml
+0
-5
ee/spec/models/elasticsearch_indexed_namespace_spec.rb
ee/spec/models/elasticsearch_indexed_namespace_spec.rb
+10
-18
No files found.
ee/app/models/elasticsearch_indexed_namespace.rb
View file @
c947b6d5
...
@@ -27,7 +27,6 @@ class ElasticsearchIndexedNamespace < ApplicationRecord
...
@@ -27,7 +27,6 @@ class ElasticsearchIndexedNamespace < ApplicationRecord
end
end
def
self
.
drop_limited_ids_cache!
def
self
.
drop_limited_ids_cache!
# To prevent stale cache we also drop ElasticsearchIndexedProject cache since it uses ElasticsearchIndexedNamespace
ElasticsearchIndexedProject
.
drop_limited_ids_cache!
ElasticsearchIndexedProject
.
drop_limited_ids_cache!
super
super
end
end
...
@@ -57,8 +56,6 @@ class ElasticsearchIndexedNamespace < ApplicationRecord
...
@@ -57,8 +56,6 @@ class ElasticsearchIndexedNamespace < ApplicationRecord
ElasticNamespaceIndexerWorker
.
bulk_perform_async
(
jobs
)
# rubocop:disable Scalability/BulkPerformWithContext, CodeReuse/Worker
ElasticNamespaceIndexerWorker
.
bulk_perform_async
(
jobs
)
# rubocop:disable Scalability/BulkPerformWithContext, CodeReuse/Worker
end
end
drop_limited_ids_cache!
end
end
def
self
.
unindex_last_n_namespaces_of_plan
(
plan
,
number_of_namespaces
)
def
self
.
unindex_last_n_namespaces_of_plan
(
plan
,
number_of_namespaces
)
...
@@ -76,8 +73,6 @@ class ElasticsearchIndexedNamespace < ApplicationRecord
...
@@ -76,8 +73,6 @@ class ElasticsearchIndexedNamespace < ApplicationRecord
ElasticNamespaceIndexerWorker
.
bulk_perform_async
(
jobs
)
# rubocop:disable Scalability/BulkPerformWithContext, CodeReuse/Worker
ElasticNamespaceIndexerWorker
.
bulk_perform_async
(
jobs
)
# rubocop:disable Scalability/BulkPerformWithContext, CodeReuse/Worker
end
end
drop_limited_ids_cache!
end
end
private
private
...
...
ee/changelogs/unreleased/213777-fix-stale-cache-bug.yml
deleted
100644 → 0
View file @
87a600de
---
title
:
Fix Elasticsearch rollout stale cache bug
merge_request
:
29233
author
:
type
:
fixed
ee/spec/models/elasticsearch_indexed_namespace_spec.rb
View file @
c947b6d5
...
@@ -39,7 +39,7 @@ describe ElasticsearchIndexedNamespace do
...
@@ -39,7 +39,7 @@ describe ElasticsearchIndexedNamespace do
end
end
end
end
context
'with plans'
,
:use_clean_rails_redis_caching
do
context
'with plans'
do
Plan
::
PAID_HOSTED_PLANS
.
each
do
|
plan
|
Plan
::
PAID_HOSTED_PLANS
.
each
do
|
plan
|
plan_factory
=
"
#{
plan
}
_plan"
plan_factory
=
"
#{
plan
}
_plan"
let_it_be
(
plan_factory
)
{
create
(
plan_factory
)
}
let_it_be
(
plan_factory
)
{
create
(
plan_factory
)
}
...
@@ -54,11 +54,8 @@ describe ElasticsearchIndexedNamespace do
...
@@ -54,11 +54,8 @@ describe ElasticsearchIndexedNamespace do
stub_ee_application_setting
(
elasticsearch_indexing:
false
)
stub_ee_application_setting
(
elasticsearch_indexing:
false
)
end
end
def
expect_indexed_namespaces_to_match
(
array
)
def
get_indexed_namespaces
ids
=
described_class
.
order
(
:created_at
).
pluck
(
:namespace_id
)
described_class
.
order
(
:created_at
).
pluck
(
:namespace_id
)
expect
(
ids
).
to
eq
(
array
)
expect
(
ids
).
to
match_array
(
described_class
.
limited_ids_cached
)
end
end
def
expect_queue_to_contain
(
*
args
)
def
expect_queue_to_contain
(
*
args
)
...
@@ -69,23 +66,21 @@ describe ElasticsearchIndexedNamespace do
...
@@ -69,23 +66,21 @@ describe ElasticsearchIndexedNamespace do
describe
'.index_first_n_namespaces_of_plan'
do
describe
'.index_first_n_namespaces_of_plan'
do
it
'creates records, scoped by plan and ordered by namespace id'
do
it
'creates records, scoped by plan and ordered by namespace id'
do
expect
(
ElasticsearchIndexedNamespace
).
to
receive
(
:drop_limited_ids_cache!
).
and_call_original
.
exactly
(
3
).
times
ids
=
namespaces
.
map
(
&
:id
)
ids
=
namespaces
.
map
(
&
:id
)
described_class
.
index_first_n_namespaces_of_plan
(
'gold'
,
1
)
described_class
.
index_first_n_namespaces_of_plan
(
'gold'
,
1
)
expect
_indexed_namespaces_to_match
([
ids
[
0
]])
expect
(
get_indexed_namespaces
).
to
eq
([
ids
[
0
]])
expect_queue_to_contain
(
ids
[
0
],
"index"
)
expect_queue_to_contain
(
ids
[
0
],
"index"
)
described_class
.
index_first_n_namespaces_of_plan
(
'gold'
,
2
)
described_class
.
index_first_n_namespaces_of_plan
(
'gold'
,
2
)
expect
_indexed_namespaces_to_match
([
ids
[
0
],
ids
[
2
]])
expect
(
get_indexed_namespaces
).
to
eq
([
ids
[
0
],
ids
[
2
]])
expect_queue_to_contain
(
ids
[
2
],
"index"
)
expect_queue_to_contain
(
ids
[
2
],
"index"
)
described_class
.
index_first_n_namespaces_of_plan
(
'silver'
,
1
)
described_class
.
index_first_n_namespaces_of_plan
(
'silver'
,
1
)
expect
_indexed_namespaces_to_match
([
ids
[
0
],
ids
[
2
],
ids
[
1
]])
expect
(
get_indexed_namespaces
).
to
eq
([
ids
[
0
],
ids
[
2
],
ids
[
1
]])
expect_queue_to_contain
(
ids
[
1
],
"index"
)
expect_queue_to_contain
(
ids
[
1
],
"index"
)
end
end
end
end
...
@@ -97,26 +92,23 @@ describe ElasticsearchIndexedNamespace do
...
@@ -97,26 +92,23 @@ describe ElasticsearchIndexedNamespace do
end
end
it
'creates records, scoped by plan and ordered by namespace id'
do
it
'creates records, scoped by plan and ordered by namespace id'
do
expect
(
ElasticsearchIndexedNamespace
).
to
receive
(
:drop_limited_ids_cache!
).
and_call_original
.
exactly
(
3
).
times
ids
=
namespaces
.
map
(
&
:id
)
ids
=
namespaces
.
map
(
&
:id
)
expect
_indexed_namespaces_to_match
([
ids
[
0
],
ids
[
2
],
ids
[
1
]
])
expect
(
get_indexed_namespaces
).
to
contain_exactly
(
ids
[
0
],
ids
[
2
],
ids
[
1
])
described_class
.
unindex_last_n_namespaces_of_plan
(
'gold'
,
1
)
described_class
.
unindex_last_n_namespaces_of_plan
(
'gold'
,
1
)
expect
_indexed_namespaces_to_match
([
ids
[
0
],
ids
[
1
]
])
expect
(
get_indexed_namespaces
).
to
contain_exactly
(
ids
[
0
],
ids
[
1
])
expect_queue_to_contain
(
ids
[
2
],
"delete"
)
expect_queue_to_contain
(
ids
[
2
],
"delete"
)
described_class
.
unindex_last_n_namespaces_of_plan
(
'silver'
,
1
)
described_class
.
unindex_last_n_namespaces_of_plan
(
'silver'
,
1
)
expect_indexed_namespaces_to_match
([
ids
[
0
]])
expect
(
get_indexed_namespaces
).
to
contain_exactly
(
ids
[
0
])
expect_queue_to_contain
(
ids
[
1
],
"delete"
)
expect_queue_to_contain
(
ids
[
1
],
"delete"
)
described_class
.
unindex_last_n_namespaces_of_plan
(
'gold'
,
1
)
described_class
.
unindex_last_n_namespaces_of_plan
(
'gold'
,
1
)
expect
_indexed_namespaces_to_match
([])
expect
(
get_indexed_namespaces
).
to
be_empty
expect_queue_to_contain
(
ids
[
0
],
"delete"
)
expect_queue_to_contain
(
ids
[
0
],
"delete"
)
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