diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /lib/gitlab/database/migration_helpers/automatic_lock_writes_on_tables.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) | |
download | gitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'lib/gitlab/database/migration_helpers/automatic_lock_writes_on_tables.rb')
-rw-r--r-- | lib/gitlab/database/migration_helpers/automatic_lock_writes_on_tables.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/gitlab/database/migration_helpers/automatic_lock_writes_on_tables.rb b/lib/gitlab/database/migration_helpers/automatic_lock_writes_on_tables.rb index 0aa4b0d01c4..c59139344ea 100644 --- a/lib/gitlab/database/migration_helpers/automatic_lock_writes_on_tables.rb +++ b/lib/gitlab/database/migration_helpers/automatic_lock_writes_on_tables.rb @@ -42,7 +42,7 @@ module Gitlab def should_lock_writes_on_table?(table_name) # currently gitlab_schema represents only present existing tables, this is workaround for deleted tables # that should be skipped as they will be removed in a future migration. - return false if Gitlab::Database::GitlabSchema::DELETED_TABLES[table_name] + return false if Gitlab::Database::GitlabSchema.deleted_tables_to_schema[table_name] table_schema = Gitlab::Database::GitlabSchema.table_schema(table_name.to_s, undefined: false) @@ -60,12 +60,15 @@ module Gitlab Gitlab::Database.gitlab_schemas_for_connection(connection).exclude?(table_schema) end + # with_retries creates new a transaction. So we set it to false if the connection is + # already has an open transaction, to avoid sub-transactions. def lock_writes_on_table(connection, table_name) database_name = Gitlab::Database.db_config_name(connection) LockWritesManager.new( table_name: table_name, connection: connection, database_name: database_name, + with_retries: !connection.transaction_open?, logger: Logger.new($stdout) ).lock_writes end |