Make Zoekt force re-indexing probability configurable

What does this MR do and why?

Make the Zoekt force re-indexing probability configurable to allow tuning and provide flexibility for Self-Managed and Dedicated customers.

The REINDEXING_CHANCE_PERCENTAGE was previously hardcoded at 0.5%, which caused excessive work for very large repositories. This change makes it configurable via Admin UI settings and reduces the default to 0.25%.

Changes:

  • Add zoekt_reindexing_chance_percentage setting to Search::Zoekt::Settings
  • Add jsonb_accessor in ApplicationSetting with default of 0.25% (reduced from 0.5%)
  • Add JSON schema validation for the new setting
  • Add validation ensuring value is between 0-100
  • Update IndexingTaskService to use configurable setting instead of hardcoded constant
  • Add proper handling for 0% (disables random re-indexing) and 100% (always forces re-indexing)
  • Add comprehensive test coverage including edge cases
  • Update documentation with new setting usage

The setting can be configured via Admin > Settings > Search > Exact code search. It is positioned after "Indexing CPU to tasks multiplier" for logical grouping with other resource/performance-related indexing settings.

References

Closes #586407 (closed)

Screenshots or screen recordings

Before After
CleanShot_2026-02-05_at_12.09.11 CleanShot_2026-02-05_at_16.35.35

How to set up and validate locally

  1. Start your GDK and ensure Zoekt is enabled
  2. Navigate to Admin > Settings > Search > Exact code search
  3. Locate the "Probability of random force re-indexing (%)" field (positioned after "Indexing CPU to tasks multiplier")
  4. Set a value between 0 and 100:
    • 0 - Disables random force re-indexing completely
    • 0.25 - Default (0.25% probability)
    • 100 - Always forces re-indexing
  5. Save changes
  6. Verify the setting is persisted by refreshing the page
  7. In a Rails console, verify the setting:
    ApplicationSetting.current.zoekt_reindexing_chance_percentage
    # => 0.25 (or your configured value)
  8. Verify it's used in the service:
    Search::Zoekt::Settings.reindexing_chance_percentage
    # => 0.25 (or your configured value)

MR acceptance checklist

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

Edited by Dmitry Gruzd

Merge request reports

Loading