Add concurrency_limit to Security::SyncPolicyWorker

What does this MR do and why?

Adds an explicit concurrency_limit -> { 300 } to Security::SyncPolicyWorker.

The worker fans out a single policy change to up to thousands of Security::SyncProjectPolicyWorker jobs via batched bulk_perform_in_with_contexts calls. Capping in-flight SyncPolicyWorker jobs:

  • Bounds the rate at which downstream jobs are produced and aligns with the existing concurrency_limit -> { 300 } on Security::SyncProjectPolicyWorker.
  • Provides a deterministic ceiling on GitLab Dedicated, where GITLAB_SIDEKIQ_MAX_REPLICAS=0 makes the capacity-based default concurrency limit ineffective.
  • Adds backpressure against bulk operations (mass policy resync, large CSP rollouts) that previously could saturate the catchall shard.

Jobs above the limit are deferred to a Redis LIST and re-enqueued by ConcurrencyLimit::ResumeWorker (cron */1 * * * *), so the maximum added latency under throttling is ~60 seconds.

Interactions verified

  • deduplicate :until_executing, including_scheduled: true — client middleware order is DuplicateJobs::Client → ConcurrencyLimit::Client, so duplicate events for the same security_policy_id collapse before reaching the throttle LIST.
  • data_consistency :sticky — wal_locations are serialized into the deferred-job payload and restored on resume, preserving replica stickiness.
  • EventStore::Subscriber — events are considered consumed once enqueued, so no redelivery occurs.
  • idempotent! — re-runs on the resume path remain safe.

Screenshots or screen recordings

N/A — Sidekiq worker attribute change with no UI impact.

How to set up and validate locally

  1. In Rails console, confirm the configured limit:

    Security::SyncPolicyWorker.get_concurrency_limit
    # => 300
  2. Trigger a policy change and observe the worker is enqueued normally under typical load.

  3. Optionally inspect deferred-jobs metrics:

    • sidekiq_concurrency_limit_queue_jobs{worker="Security::SyncPolicyWorker"}
    • sidekiq_concurrency_limit_deferred_jobs_total{worker="Security::SyncPolicyWorker"}

References

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Merge request reports

Loading
Loading