Class: BatchedGitRefUpdates::CleanupSchedulerService
- Inherits:
-
Object
- Object
- BatchedGitRefUpdates::CleanupSchedulerService
- Includes:
- Gitlab::ExclusiveLeaseHelpers
- Defined in:
- app/services/batched_git_ref_updates/cleanup_scheduler_service.rb
Constant Summary collapse
- MAX_PROJECTS =
10_000
- BATCH_SIZE =
100
- LOCK_TIMEOUT =
10.minutes
Constants included from Gitlab::ExclusiveLeaseHelpers
Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError
Instance Method Summary collapse
Methods included from Gitlab::ExclusiveLeaseHelpers
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/batched_git_ref_updates/cleanup_scheduler_service.rb', line 10 def execute total_projects = 0 in_lock(self.class.name, retries: 0, ttl: LOCK_TIMEOUT) do Deletion.status_pending.distinct_each_batch(column: :project_id, of: BATCH_SIZE) do |deletions| ProjectCleanupWorker.bulk_perform_async_with_contexts( deletions, arguments_proc: ->(deletion) { deletion.project_id }, context_proc: ->(_) { {} } # No project context because loading the project is wasteful ) total_projects += deletions.count break if total_projects >= MAX_PROJECTS end end { total_projects: total_projects } end |