[go: up one dir, main page]

feat: Enable automatic DB reindexing using CronJob

What does this MR do?

feat: Enable automatic DB reindexing using CronJob

Related to gitlab-com/gl-infra/delivery#21668

Automatic database reindexing is possible in an Omnibus installation by flipping some configuration values inside the gitlab.rb file. As far as I can tell, Helm chart installations that use CNG (Cloud Native GitLab) container images do not have a native method for runnig reindexing periodically.

The Toolbox chart already has a CronJob for taking a backup. So, I am proposing that we add a CronJob that will perform automatic database reindexing on a user-specified schedule.

The script that is mentioned in this MR is added to the Rails image in this CNG MR: gitlab-org/build/CNG!2712 As usual, before running the script, we ensure that the dependencies (Postgres and Redis) are accessible.

The script will run a Rake task, which emulates the behavior from Omnibus, when the configuration flags mentioned here are enabled: https://gitlab.com/gitlab-org/omnibus-gitlab/-/blob/b26f58eb8a5e14be5ee3ddc6c16a8ecf9a462181/files/gitlab-cookbooks/gitlab/recipes/database_reindexing_enable.rb#L27

Changelog: added

What Does gitlab:db:reindex Do?

This Rake task has limitations on the job's workload that are defined inside the GitLab codebase: It will create at most 2 indexes (asynchronously) and re-index at most 2 existing indexes. So, it will not run indefinitely, and we don't need to impose any other limits on it. The code identifies what to re-index using an index bloat heuristic.

  1. db.rake
    1. Async index creation
      1. At most 2 indexes will be created
    2. Async constraint validation
      1. At most 2 constraints will be validated
    3. Reindexing
      1. At most 2 existing indexes will be reindexed

Author checklist

For general guidance, please follow our Contributing guide.

Required

For anything in this list which will not be completed, please provide a reason in the MR discussion.

  • Merge Request Title and Description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • MR has a green pipeline.
  • Documentation created/updated.
  • Tests added/updated, and test plan for scenarios not covered by automated tests.
  • Equivalent MR/issue for omnibus-gitlab opened.

Reviewers checklist

Edited by Siddharth Kannan

Merge request reports

Loading