Zoekt: Fix missing repo logic

What does this MR do and why?

This MR fixes a problem we had with indexing projects when there is no repository. Such projects caused the index and repositories to be stuck in initializing.

Duo summary:

This merge request updates the task processing logic for a search system. The main changes include:

  1. Refactoring the task state determination process, introducing a new 'done' state for tasks with nothing to index.
  2. Updating how task states are handled and stored, with separate handling for valid, orphaned, skipped, and done tasks.
  3. Modifying the update process for task states, including updating the associated repository state to 'ready' for done tasks.
  4. Adjusting the test expectations to reflect the new 'done' state instead of 'orphaned' for certain scenarios.

These changes aim to improve the efficiency and accuracy of task processing in the search system, providing more granular control over task states and their associated repositories.

DB queries

Search::Zoekt::Repository.id_in(Search::Zoekt::Task.id_in(states[:done]).select(:zoekt_repository_id)).update_all(state: :ready)

https://postgres.ai/console/gitlab/gitlab-production-main/sessions/36647/commands/112513

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Related to #521189 (closed)

Edited by Dmitry Gruzd

Merge request reports

Loading