Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cleanup_worker.rb « loose_foreign_keys « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b4565dbf6244d32fec93501644d7f06b55586f20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module LooseForeignKeys
  class CleanupWorker
    include ApplicationWorker
    include Gitlab::ExclusiveLeaseHelpers
    include CronjobQueue # rubocop: disable Scalability/CronWorkerContext

    feature_category :sharding
    data_consistency :always
    idempotent!

    def perform
      return if Feature.disabled?(:loose_foreign_key_cleanup, default_enabled: :yaml)

      ttl = ModificationTracker::MAX_RUNTIME + 1.minute
      in_lock(self.class.name.underscore, ttl: ttl, retries: 0) do
        # TODO: Iterate over the connections
        # https://gitlab.com/gitlab-org/gitlab/-/issues/341513
        stats = ProcessDeletedRecordsService.new(connection: ApplicationRecord.connection).execute
        log_extra_metadata_on_done(:stats, stats)
      end
    end
  end
end