Module: BackgroundMigration::SingleDatabaseWorker
- Extended by:
- ActiveSupport::Concern
- Includes:
- ApplicationWorker
- Included in:
- CiDatabaseWorker, BackgroundMigrationWorker
- Defined in:
- app/workers/background_migration/single_database_worker.rb
Constant Summary collapse
- MAX_LEASE_ATTEMPTS =
5
- BACKGROUND_MIGRATIONS_DELAY =
4.hours.freeze
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_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Method Summary collapse
-
#perform(class_name, arguments = [], lease_attempts = MAX_LEASE_ATTEMPTS) ⇒ Object
Performs the background migration.
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Method Details
#perform(class_name, arguments = [], lease_attempts = MAX_LEASE_ATTEMPTS) ⇒ Object
Performs the background migration.
See Gitlab::BackgroundMigration.perform for more information.
class_name - The class name of the background migration to run. arguments - The arguments to pass to the migration class. lease_attempts - The number of times we will try to obtain an exclusive
lease on the class before giving up. See MR for more discussion.
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45298#note_434304956
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/workers/background_migration/single_database_worker.rb', line 47 def perform(class_name, arguments = [], lease_attempts = MAX_LEASE_ATTEMPTS) should_skip = Feature.enabled?(:disallow_database_ddl_feature_flags, type: :ops) || Feature.disabled?(:execute_background_migrations, type: :ops) if should_skip # Delay execution of background migrations self.class.perform_in(BACKGROUND_MIGRATIONS_DELAY, class_name, arguments, lease_attempts) Sidekiq.logger.info( class: self.class.name, database: self.class.tracking_database, message: 'skipping execution, migration rescheduled') return end job_coordinator.with_shared_connection do perform_with_connection(class_name, arguments, lease_attempts) end end |