diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
commit | 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch) | |
tree | 6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /lib/tasks/gitlab/db/lock_writes.rake | |
parent | a7253423e3403b8c08f8a161e5937e1488f5f407 (diff) |
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'lib/tasks/gitlab/db/lock_writes.rake')
-rw-r--r-- | lib/tasks/gitlab/db/lock_writes.rake | 51 |
1 files changed, 12 insertions, 39 deletions
diff --git a/lib/tasks/gitlab/db/lock_writes.rake b/lib/tasks/gitlab/db/lock_writes.rake index 212d60a7231..59478d47d12 100644 --- a/lib/tasks/gitlab/db/lock_writes.rake +++ b/lib/tasks/gitlab/db/lock_writes.rake @@ -4,49 +4,22 @@ namespace :gitlab do namespace :db do desc "GitLab | DB | Install prevent write triggers on all databases" task lock_writes: [:environment, 'gitlab:db:validate_config'] do - Gitlab::Database::EachDatabase.each_database_connection(include_shared: false) do |connection, database_name| - schemas_for_connection = Gitlab::Database.gitlab_schemas_for_connection(connection) - - Gitlab::Database::LockWritesManager.tables_to_lock(connection) do |table_name, schema_name| - # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/366834 - next if schema_name == :gitlab_geo - - lock_writes_manager = Gitlab::Database::LockWritesManager.new( - table_name: table_name, - connection: connection, - database_name: database_name, - with_retries: true, - logger: Logger.new($stdout), - dry_run: ENV['DRY_RUN'] == 'true' - ) - - if schemas_for_connection.include?(schema_name.to_sym) - lock_writes_manager.unlock_writes - else - lock_writes_manager.lock_writes - end - end - end + logger = Logger.new($stdout) + logger.level = Gitlab::Utils.to_boolean(ENV['VERBOSE']) ? Logger::INFO : Logger::WARN + Gitlab::Database::TablesLocker.new( + logger: logger, + dry_run: Gitlab::Utils.to_boolean(ENV['DRY_RUN'], default: false) + ).lock_writes end desc "GitLab | DB | Remove all triggers that prevents writes from all databases" task unlock_writes: :environment do - Gitlab::Database::EachDatabase.each_database_connection do |connection, database_name| - Gitlab::Database::LockWritesManager.tables_to_lock(connection) do |table_name, schema_name| - # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/366834 - next if schema_name == :gitlab_geo - - lock_writes_manager = Gitlab::Database::LockWritesManager.new( - table_name: table_name, - connection: connection, - database_name: database_name, - with_retries: true, - logger: Logger.new($stdout) - ) - - lock_writes_manager.unlock_writes - end - end + logger = Logger.new($stdout) + logger.level = Gitlab::Utils.to_boolean(ENV['VERBOSE']) ? Logger::INFO : Logger::WARN + Gitlab::Database::TablesLocker.new( + logger: logger, + dry_run: Gitlab::Utils.to_boolean(ENV['DRY_RUN'], default: false) + ).unlock_writes end end end |