Backport of 'Back off StoreScansWorker retries on lease contention' to 19.5
What does this MR do and why?
This MR backports !262568 (merged) to 19-5-stable-ee.
The MR is a git cherry-pick -x of the squash commit fba32c3a. The pick applied with no conflicts. The patch is identical to the default branch commit (same git patch-id).
What is backported
Security::StoreGroupedScansServicecallsin_lockwithretries: 0. The job tries for the store lease one time and does not sleep in the Sidekiq thread.- When another job holds the lease, the service raises the new
Security::StoreGroupedScansService::LeaseTakenError. This class is a subclass ofGitlab::SidekiqMiddleware::RetryError, so the error does not go to Sentry or count against the execution SLI. Security::StoreScansWorkergets asidekiq_retry_inblock. ForLeaseTakenError, the retry delays are 1, 2, 4, 8 and 16 minutes. For all other errors, Sidekiq uses its default delay.Security::StoreScansWorkerretries 5 times instead of 3.spec/workers/every_sidekiq_worker_spec.rbhas the new retry count.
Why
The store lease is per pipeline and report file type, with a TTL of 30 minutes. Before this change, a job that did not get the lease waited for it in its Sidekiq thread for about 30 seconds. Then the worker used its next retry with the default delay. All 4 attempts ran in about 3 to 4 minutes. If the lease holder took longer than that, the waiting job failed permanently and did not store its scans.
With this change, the retries cover more than the lease TTL (31 minutes in total). The waiting job does not block a Sidekiq thread.
The related confidential issue https://gitlab.com/gitlab-org/gitlab/-/work_items/633845 has the details.
Risk
Security::StoreScansWorkeris the only production caller of this code path. No web request depends on the old wait behavior.- Other errors also get the 2 extra retries, with the default delay.
Default branch status
| Item | Value |
|---|---|
| Default branch MR | !262568 (merged) |
| Squash commit | fba32c3a |
| Merged | 2026-10-21 |
| First deployed to GitLab.com production | 2026-10-21 |
Testing on 19-5-stable-ee
I ran these specs on the backport commit, on top of 19-5-stable-ee:
| Spec | Result |
|---|---|
ee/spec/services/security/store_grouped_scans_service_spec.rb, ee/spec/workers/security/store_scans_worker_spec.rb, ee/spec/services/security/store_grouped_sbom_scans_service_spec.rb and ee/spec/services/security/store_scans_service_spec.rb |
70 examples, 0 failures |
RuboCop found no offenses in the 5 changed files.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
- This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
- The MR that fixed the bug on the default branch has been deployed to GitLab.com (not applicable for documentation or spec changes).
- The MR title is descriptive (e.g. "Backport of 'title of default branch MR'"). This is important, since the title will be copied to the patch blog post.
- Required labels have been applied to this merge request
- severity label and bug subtype labels (if applicable)
- If this MR fixes a bug that affects customers, the customer label has been applied.
- This MR has been approved by a maintainer (only one approval is required).
- Ensure the
E2E Omnibus GitLab EEpipeline (triggered by thee2e:test-on-omnibus-eejob) has succeeded. If it has failed (or shows warnings), investigate the failures. If you determine the failures are unrelated, you may proceed. If you need assistance investigating, request help in the #s_developer_experience Slack channel to confirm the failures are unrelated to the merge request.
Note to the merge request author and maintainer
If you have questions about the patch release process, please:
- Refer to the patch release runbook for engineers and maintainers for guidance.
- Ask questions on the
#releasesSlack channel (internal only). - Once the backport has been merged, the commit changes will be automatically deployed to a release environment that can be used for manual validation. See after merging runbook for details.