diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-18 21:08:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-18 21:08:05 +0300 |
commit | 6b5d8b17e28741bccf31029633cc5af7ceab1486 (patch) | |
tree | 38732dffc21a5084b5c3d49b56b81aa11b4e657e /app/workers/database/batched_background_migration/single_database_worker.rb | |
parent | a84995f457d775bb73598d4393c3bc99805d9b58 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers/database/batched_background_migration/single_database_worker.rb')
-rw-r--r-- | app/workers/database/batched_background_migration/single_database_worker.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/app/workers/database/batched_background_migration/single_database_worker.rb b/app/workers/database/batched_background_migration/single_database_worker.rb index aeadda4b8e1..8a0de268048 100644 --- a/app/workers/database/batched_background_migration/single_database_worker.rb +++ b/app/workers/database/batched_background_migration/single_database_worker.rb @@ -7,6 +7,7 @@ module Database include ApplicationWorker include CronjobQueue # rubocop:disable Scalability/CronWorkerContext + include Gitlab::Utils::StrongMemoize LEASE_TIMEOUT_MULTIPLIER = 3 MINIMUM_LEASE_TIMEOUT = 10.minutes.freeze @@ -44,6 +45,15 @@ module Database return end + if shares_db_config? + Sidekiq.logger.info( + class: self.class.name, + database: self.class.tracking_database, + message: 'skipping migration execution for database that shares database configuration with another database') + + return + end + Gitlab::Database::SharedModel.using_connection(base_model.connection) do break unless self.class.enabled? && active_migration @@ -63,7 +73,7 @@ module Database private def active_migration - @active_migration ||= Gitlab::Database::BackgroundMigration::BatchedMigration.active_migration + @active_migration ||= Gitlab::Database::BackgroundMigration::BatchedMigration.active_migration(connection: base_model.connection) end def run_active_migration @@ -71,7 +81,13 @@ module Database end def base_model - @base_model ||= Gitlab::Database.database_base_models[self.class.tracking_database] + strong_memoize(:base_model) do + Gitlab::Database.database_base_models[self.class.tracking_database] + end + end + + def shares_db_config? + base_model && Gitlab::Database.db_config_share_with(base_model.connection_db_config).present? end def with_exclusive_lease(interval) |