Class: LooseForeignKeys::CleanupWorker
- Inherits:
-
Object
- Object
- LooseForeignKeys::CleanupWorker
- Defined in:
- app/workers/loose_foreign_keys/cleanup_worker.rb
Constant Summary
Constants included from Gitlab::ExclusiveLeaseHelpers
Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Gitlab::Loggable
Constants included from WorkerAttributes
WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Method Summary collapse
Methods included from Gitlab::ExclusiveLeaseHelpers
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Method Details
#perform ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/workers/loose_foreign_keys/cleanup_worker.rb', line 14 def perform connection_name, base_model = current_connection_name_and_base_model modification_tracker, turbo_mode = initialize_modification_tracker_for(connection_name) # Add small buffer on MAX_RUNTIME to account for single long running # query or extra worker time after the cleanup. lock_ttl = modification_tracker.max_runtime + 10.seconds in_lock(self.class.name.underscore, ttl: lock_ttl, retries: 0) do stats = ProcessDeletedRecordsService.new( connection: base_model.connection, modification_tracker: modification_tracker, logger: Sidekiq.logger ).execute stats[:connection] = connection_name stats[:turbo_mode] = turbo_mode (:stats, stats) end end |