Loading
Wait longer for locks when finalizing pending detach partitions
What does this MR do and why?
Context
On GitLab.com, ci_build_trace_metadata_102 is still pending detach. Every attempt by Database::FinalizePendingDetachPartitionsWorker to finalize it times out on the locks on p_ci_builds and p_ci_job_artifacts. Running the worker more often overnight (!263720 (merged)) didn't help, because the partitioning lock retries never wait longer than 1s. In #631599 (comment 4105946969), it's suggested we try a longer lock timeout.
This MR
- Each round of the finalizer's lock retries now ends with longer attempts: 3s, then 4.5s. We stop just under GitLab.com's 5s
deadlock_timeout, because a longer wait would cancel any regular autovacuum blocking it. - Writes to
p_ci_buildsandp_ci_job_artifactsqueue behind each wait. A failing 3s or 4.5s attempt can stall them for up to about 6s or 9s, which stays under the 15sstatement_timeout. The worker runs only between 23:00 and 04:45 UTC. - The dropper's own finalize attempt uses the new ladder too. Other
WithPartitioningLockRetriescallers keep the default ladder.
This gives the finalizer a chance to get past blockers that clear within a few seconds.
References
- [FF] `ci_finalize_pending_detach_partitions_dai... (#631599)
- Feature flag rollout: Enable `ci_detach_archive... (#617932)
- Finalize pending detach partitions more often o... (!263720 - merged)
How to set up and validate locally
- Run the specs:
All examples pass.
bin/rspec spec/lib/gitlab/database/partitioning/pending_detach_partition_finalizer_spec.rb spec/lib/gitlab/database/partitioning/with_partitioning_lock_retries_spec.rb
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.