Skip to content
Snippets Groups Projects

Draft: Only check index integrity when commit_count is > 0

Closed Terri Chu requested to merge 214601-refactor-when-blobs-are-missing into master
1 unresolved thread

What does this MR do and why?

Related to #214601 (closed)

We introduced index integrity check and when reviewing kibana logs, I suspect that the index integrity check is not using the repository methods correctly.

Advanced Search only indexes the default branch, so we should only check projects when:

  • repository exists
  • repository is not empty
  • repository has a commit_count > 0 (commit_count is run against the root_ref so it's only for the default branch)

This change adds the commit_count check. The commit_count method checks that a root_ref exists, and gets a commit_count for the root_ref (Default branch). This should ensure that in most cases there are files in the repository for the default branch. I also removed the call to repository.exists? since repository.empty? checks that the repository exists, so we don't need to call that twice.

Screenshots or screen recordings

N/A

How to set up and validate locally

I'm not sure how to setup a non-empty repository with a default branch that is empty and has no commits, but you can setup empty branches.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Terri Chu

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1081 1081 end
1082 1082
1083 1083 def should_check_index_integrity?
1084 use_elasticsearch? && repository_exists? && !empty_repo?
1084 use_elasticsearch? && !empty_repo? && statistics&.commit_count.to_i > 0
  • Author Maintainer

    note: empty_repo? calls exists? on the repository so the extra check is not needed

    question: should this make a call to repository.commit_count vs. statistics? I wondered if statistics might not be up to date, but I thought that might be an edge case

  • Please register or sign in to reply
  • Terri Chu changed the description

    changed the description

  • Author Maintainer

    I'm closing this MR. After some further research, I trust empty_repo? and exists? to tell the project needs to be checked

  • closed

  • Please register or sign in to reply
    Loading