Class: Database::BackgroundOperation::BaseOrchestratorWorker
- Inherits:
-
Object
- Object
- Database::BackgroundOperation::BaseOrchestratorWorker
- Includes:
- ApplicationWorker, ExclusiveLeaseGuard, Gitlab::Utils::StrongMemoize, LimitedCapacity::Worker
- Defined in:
- app/workers/database/background_operation/base_orchestrator_worker.rb
Overview
rubocop:disable Scalability/IdempotentWorker – A LimitedCapacity::Worker
Direct Known Subclasses
CiOrchestratorCellLocalWorker, CiOrchestratorWorker, MainOrchestratorCellLocalWorker, MainOrchestratorWorker, SecOrchestratorCellLocalWorker, SecOrchestratorWorker
Constant Summary collapse
- INTERVAL_VARIANCE =
5.seconds.freeze
- LEASE_TIMEOUT_MULTIPLIER =
3
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Gitlab::Loggable
Constants included from WorkerAttributes
WorkerAttributes::DEFAULT_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, 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
Class Method Summary collapse
- .max_running_jobs ⇒ Object
-
.perform_with_capacity(args) ⇒ Object
We have to override this one, as we want arguments passed as is, and not duplicated.
Instance Method Summary collapse
- #max_running_jobs ⇒ Object
- #perform_work(worker_class, worker_partition, worker_id, database_name) ⇒ Object
- #remaining_work_count(*_args) ⇒ Object
Methods included from LimitedCapacity::Worker
#perform, #remove_failed_jobs, #report_prometheus_metrics
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Methods included from ExclusiveLeaseGuard
#exclusive_lease, #lease_release?, #lease_taken_log_level, #lease_taken_message, #log_lease_taken, #release_lease, #renew_lease!, #try_obtain_lease
Class Method Details
.max_running_jobs ⇒ Object
29 30 31 |
# File 'app/workers/database/background_operation/base_orchestrator_worker.rb', line 29 def max_running_jobs Gitlab::CurrentSettings.background_operations_max_jobs end |
.perform_with_capacity(args) ⇒ Object
We have to override this one, as we want arguments passed as is, and not duplicated
22 23 24 25 26 27 |
# File 'app/workers/database/background_operation/base_orchestrator_worker.rb', line 22 def perform_with_capacity(args) worker = new worker.remove_failed_jobs bulk_perform_async(args) end |
Instance Method Details
#max_running_jobs ⇒ Object
55 56 57 |
# File 'app/workers/database/background_operation/base_orchestrator_worker.rb', line 55 def max_running_jobs self.class.max_running_jobs end |
#perform_work(worker_class, worker_partition, worker_id, database_name) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/workers/database/background_operation/base_orchestrator_worker.rb', line 34 def perform_work(worker_class, worker_partition, worker_id, database_name) self.database_name = database_name self.worker_class = worker_class return if shares_db_config? Gitlab::Database::SharedModel.using_connection(base_model.connection) do self.worker = find_worker(worker_partition, worker_id) break unless worker.present? try_obtain_lease do run_operation_job if runnable_worker? end end end |
#remaining_work_count(*_args) ⇒ Object
51 52 53 |
# File 'app/workers/database/background_operation/base_orchestrator_worker.rb', line 51 def remaining_work_count(*_args) 0 # the cron worker is the only source of new jobs end |