Skip to content

Embed db health check options in sidekiq jobs

What does this MR do and why?

This is part II of #404898 (closed), part I being !120982 (merged) which brought database health check framework under common namespace.

This MR exposes necessary methods on sidekiq workers to the perform database health check. Those attrs are used to define the context which is used by health check indicators.

Part III will perform the actual db health check and throttle (defer) the sidekiq job if needed.


Note: The initial effort was done in MR#119187 which has the entire changeset and became huge, so split it into smaller MRs to have more control.

How to set up and validate locally

  1. Choose any worker of your choice or create a new one. For this I am using 'StageUpdateWorker'.
  2. Running StageUpdateWorker.defer_on_database_health_signal? in rails console should result 'false'
  3. Enable the FF locally Feature.enable(:defer_sidekiq_workers_on_database_health_signal).
  4. Add defer_on_database_health_signal attrs in the worker class.
    class StageUpdateWorker
      ...
      ...
    
      defer_on_database_health_signal :gitlab_main, [:users]
    
      def perform(stage_id)
        Ci::Stage.find_by_id(stage_id)&.update_legacy_status
      end
    end
  5. reload! the local rails console, StageUpdateWorker.defer_on_database_health_signal? should be positive now.

MR acceptance checklist

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

Related to #404898 (closed)

Edited by Prabakaran Murugesan

Merge request reports

Loading