Discrepancy between projects_not_indexed and index_projects_status
Summary
Discovered while debugging a customer support ticket
The elastic rake tasks index_projects_status
and projects_not_indexed
can give contradicting results in certain edge cases.
Steps to reproduce
- make sure advanced search is enabled/setup for your dev environment
- make sure the index is created and complete:
bundle exec rake gitlab:elastic:index
- create a blank project with an empty repo
- run both rake tasks
-
gitlab:elastic:projects_not_indexed
will report 0 projects not indexed -
gitlab:elastic:index_projects_status
will report 1 project not indexed
What is the current bug behavior?
The rake tasks report conflicting information
Within the linked case, a customer reported that all projects were reported as indexed by projects_not_indexed
while index_projects_status
reported 99.95% complete (5782/5785) projects.
What is the expected correct behavior?
Both rake tasks should report the same information and not contradict each other.
how the rake tasks currently work
index_projects_status
does a count of IndexStatus
records and compares it to a count of Project
records. If they are equal, the task reports that all projects are indexed.
projects_not_indexed
checks for projects that do not have an index status. Also, projects without a repository (or with an empty repository) are skipped.
Possible fixes
projects_not_indexed
should include projects without a repository (empty or missing). Those projects should have IndexStatus
records according to the code in indexer.rb