Class: Ci::JobArtifacts::UpdateUnknownLockedStatusService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::ExclusiveLeaseHelpers, Gitlab::LoopHelpers
Defined in:
app/services/ci/job_artifacts/update_unknown_locked_status_service.rb

Constant Summary collapse

BATCH_SIZE =
100
LOOP_TIMEOUT =
5.minutes
LOOP_LIMIT =
100
LARGE_LOOP_LIMIT =
500
EXCLUSIVE_LOCK_KEY =
'unknown_status_job_artifacts:update:lock'
LOCK_TIMEOUT =
6.minutes

Constants included from Gitlab::ExclusiveLeaseHelpers

Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError

Instance Method Summary collapse

Methods included from Gitlab::LoopHelpers

#loop_until

Methods included from Gitlab::ExclusiveLeaseHelpers

#in_lock

Constructor Details

#initializeUpdateUnknownLockedStatusService

Returns a new instance of UpdateUnknownLockedStatusService.



16
17
18
19
20
21
# File 'app/services/ci/job_artifacts/update_unknown_locked_status_service.rb', line 16

def initialize
  @removed_count = 0
  @locked_count = 0
  @start_at = Time.current
  @loop_limit = Feature.enabled?(:ci_job_artifacts_backlog_large_loop_limit) ? LARGE_LOOP_LIMIT : LOOP_LIMIT
end

Instance Method Details

#executeObject



23
24
25
26
27
28
29
# File 'app/services/ci/job_artifacts/update_unknown_locked_status_service.rb', line 23

def execute
  in_lock(EXCLUSIVE_LOCK_KEY, ttl: LOCK_TIMEOUT, retries: 1) do
    update_locked_status_on_unknown_artifacts
  end

  { removed: @removed_count, locked: @locked_count }
end