Loading
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 }onSecurity::SyncProjectPolicyWorker. - Provides a deterministic ceiling on GitLab Dedicated, where
GITLAB_SIDEKIQ_MAX_REPLICAS=0makes 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 isDuplicateJobs::Client→ConcurrencyLimit::Client, so duplicate events for the samesecurity_policy_idcollapse before reaching the throttleLIST.data_consistency :sticky—wal_locationsare 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
-
In Rails console, confirm the configured limit:
Security::SyncPolicyWorker.get_concurrency_limit # => 300 -
Trigger a policy change and observe the worker is enqueued normally under typical load.
-
Optionally inspect deferred-jobs metrics:
sidekiq_concurrency_limit_queue_jobs{worker="Security::SyncPolicyWorker"}sidekiq_concurrency_limit_deferred_jobs_total{worker="Security::SyncPolicyWorker"}
References
- Resolves #580036 (closed)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.