Stale cache causes projects moved to indexed group not to be indexed in Elasticsearch
Summary
See !29751 (comment 325875803) :
If a project is moved from a non-elasticsearch enabled group to an elasticsearch enabled group we do not end up indexing it and searching won't work due to a stale cache entry.
Steps to reproduce
- Create 2 groups.
- Enable Elasticsearch for group 1
- Create a project in group 2
- Move that project to group 1
- Note that this project does not have advanced search enabled by trying to search it
Example Project
What is the current bug behavior?
What is the expected correct behavior?
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Possible fixes
Need to invalidate the cache when a project is moved but since this happens quite frequently we only want to invalidate the part of the cache corresponding to that project.
Workaround for indexing all projects in a namespace
From the rails console you can force it to check all projects in the namespace again and trigger indexing where necessary:
ElasticsearchIndexedNamespace.invalidate_elasticsearch_indexes_project_cache
ns = Namespace.find_by_full_path('<NAMESPACE_PATH>')
ElasticNamespaceIndexerWorker.perform_async(ns.id, :index)
Edited by Dylan Griffith