Add zoekt:reindex_failed_projects Rake task

What does this MR do and why?

Implements #550345 (closed).

Adds a Rake task gitlab:zoekt:reindex_failed_projects that allows admins to retry indexing of failed zoekt_repository records. Indexing can fail for various reasons (e.g., a repository with too many files). Over time, the number of files may be reduced, so a mechanism to retry is needed.

How it works

The task moves all failed zoekt_repository records to pending state with retries_left set to 1, so they are picked up by the next indexing cycle.

An optional comma-separated list of project IDs can be passed to limit which failed repositories are retried.

Usage

Retry all failed repositories:

gitlab-rake gitlab:zoekt:reindex_failed_projects

Retry only specific projects:

gitlab-rake "gitlab:zoekt:reindex_failed_projects[1,2,3]"

MR acceptance checklist

  • This MR follows the GitLab Contributing Guidelines
  • I have performed a self-review of this MR
  • I have added tests for this change
  • I have added documentation for this change

Changes

  • ee/app/services/search/zoekt/indexing_settings_service.rb: Add reindex_failed_projects method that processes failed repositories in batches
  • ee/app/services/search/zoekt/rake_task_executor_service.rb: Register reindex_failed_projects task and delegate to IndexingSettingsService
  • ee/lib/search/rake_task/zoekt.rb: Add reindex_failed_projects class method
  • ee/lib/tasks/gitlab/zoekt.rake: Add Rake task definition with optional project_ids argument
  • doc/integration/zoekt/_index.md: Document the new Rake task
  • Specs for all new code

Query report

Worst-case scenario

https://console.postgres.ai/gitlab/gitlab-production-main/sessions/52445/commands/153920

Edited by Ravi Kumar

Merge request reports

Loading