Commit 54ce99b8 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'app-logger-13' into 'master'

Use applogger in lib/gitlab/database/

See merge request gitlab-org/gitlab!41068
parents 1ca52df4 eb5cbb33
---
title: Use applogger in lib/gitlab/database
merge_request: 41068
author: Rajendra Kadam
type: other
...@@ -87,7 +87,7 @@ module Gitlab ...@@ -87,7 +87,7 @@ module Gitlab
options = options.merge({ algorithm: :concurrently }) options = options.merge({ algorithm: :concurrently })
if index_exists?(table_name, column_name, options) if index_exists?(table_name, column_name, options)
Rails.logger.warn "Index not created because it already exists (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn "Index not created because it already exists (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}"
return return
end end
...@@ -113,7 +113,7 @@ module Gitlab ...@@ -113,7 +113,7 @@ module Gitlab
options = options.merge({ algorithm: :concurrently }) options = options.merge({ algorithm: :concurrently })
unless index_exists?(table_name, column_name, options) unless index_exists?(table_name, column_name, options)
Rails.logger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}"
return return
end end
...@@ -143,7 +143,7 @@ module Gitlab ...@@ -143,7 +143,7 @@ module Gitlab
options = options.merge({ algorithm: :concurrently }) options = options.merge({ algorithm: :concurrently })
unless index_exists_by_name?(table_name, index_name) unless index_exists_by_name?(table_name, index_name)
Rails.logger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, index_name: #{index_name}" # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, index_name: #{index_name}"
return return
end end
...@@ -163,7 +163,6 @@ module Gitlab ...@@ -163,7 +163,6 @@ module Gitlab
# defaults to "CASCADE". # defaults to "CASCADE".
# name - The name of the foreign key. # name - The name of the foreign key.
# #
# rubocop:disable Gitlab/RailsLogger
def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, name: nil, validate: true) def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, name: nil, validate: true)
# Transactions would result in ALTER TABLE locks being held for the # Transactions would result in ALTER TABLE locks being held for the
# duration of the transaction, defeating the purpose of this method. # duration of the transaction, defeating the purpose of this method.
...@@ -183,7 +182,7 @@ module Gitlab ...@@ -183,7 +182,7 @@ module Gitlab
"source: #{source}, target: #{target}, column: #{options[:column]}, "\ "source: #{source}, target: #{target}, column: #{options[:column]}, "\
"name: #{options[:name]}, on_delete: #{options[:on_delete]}" "name: #{options[:name]}, on_delete: #{options[:on_delete]}"
Rails.logger.warn warning_message Gitlab::AppLogger.warn warning_message
else else
# Using NOT VALID allows us to create a key without immediately # Using NOT VALID allows us to create a key without immediately
# validating it. This means we keep the ALTER TABLE lock only for a # validating it. This means we keep the ALTER TABLE lock only for a
...@@ -217,7 +216,6 @@ module Gitlab ...@@ -217,7 +216,6 @@ module Gitlab
end end
end end
end end
# rubocop:enable Gitlab/RailsLogger
def validate_foreign_key(source, column, name: nil) def validate_foreign_key(source, column, name: nil)
fk_name = name || concurrent_foreign_key_name(source, column) fk_name = name || concurrent_foreign_key_name(source, column)
...@@ -1085,7 +1083,6 @@ into similar problems in the future (e.g. when new tables are created). ...@@ -1085,7 +1083,6 @@ into similar problems in the future (e.g. when new tables are created).
# Should be unique per table (not per column) # Should be unique per table (not per column)
# validate - Whether to validate the constraint in this call # validate - Whether to validate the constraint in this call
# #
# rubocop:disable Gitlab/RailsLogger
def add_check_constraint(table, check, constraint_name, validate: true) def add_check_constraint(table, check, constraint_name, validate: true)
validate_check_constraint_name!(constraint_name) validate_check_constraint_name!(constraint_name)
...@@ -1102,7 +1099,7 @@ into similar problems in the future (e.g. when new tables are created). ...@@ -1102,7 +1099,7 @@ into similar problems in the future (e.g. when new tables are created).
table: #{table}, check: #{check}, constraint name: #{constraint_name} table: #{table}, check: #{check}, constraint name: #{constraint_name}
MESSAGE MESSAGE
Rails.logger.warn warning_message Gitlab::AppLogger.warn warning_message
else else
# Only add the constraint without validating it # Only add the constraint without validating it
# Even though it is fast, ADD CONSTRAINT requires an EXCLUSIVE lock # Even though it is fast, ADD CONSTRAINT requires an EXCLUSIVE lock
...@@ -1187,7 +1184,7 @@ into similar problems in the future (e.g. when new tables are created). ...@@ -1187,7 +1184,7 @@ into similar problems in the future (e.g. when new tables are created).
column #{table}.#{column} is already defined as `NOT NULL` column #{table}.#{column} is already defined as `NOT NULL`
MESSAGE MESSAGE
Rails.logger.warn warning_message Gitlab::AppLogger.warn warning_message
end end
end end
......
...@@ -31,7 +31,7 @@ module Gitlab ...@@ -31,7 +31,7 @@ module Gitlab
current_keys << specified_key current_keys << specified_key
else else
Rails.logger.warn "foreign key not added because it already exists: #{specified_key}" # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn "foreign key not added because it already exists: #{specified_key}"
current_keys current_keys
end end
end end
...@@ -56,7 +56,7 @@ module Gitlab ...@@ -56,7 +56,7 @@ module Gitlab
existing_key.delete existing_key.delete
current_keys.delete(existing_key) current_keys.delete(existing_key)
else else
Rails.logger.warn "foreign key not removed because it doesn't exist: #{specified_key}" # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn "foreign key not removed because it doesn't exist: #{specified_key}"
end end
current_keys current_keys
......
...@@ -202,10 +202,8 @@ module Gitlab ...@@ -202,10 +202,8 @@ module Gitlab
def create_range_partitioned_copy(source_table_name, partitioned_table_name, partition_column, primary_key) def create_range_partitioned_copy(source_table_name, partitioned_table_name, partition_column, primary_key)
if table_exists?(partitioned_table_name) if table_exists?(partitioned_table_name)
# rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn "Partitioned table not created because it already exists" \
Rails.logger.warn "Partitioned table not created because it already exists" \
" (this may be due to an aborted migration or similar): table_name: #{partitioned_table_name} " " (this may be due to an aborted migration or similar): table_name: #{partitioned_table_name} "
# rubocop:enable Gitlab/RailsLogger
return return
end end
...@@ -258,10 +256,8 @@ module Gitlab ...@@ -258,10 +256,8 @@ module Gitlab
def create_range_partition_safely(partition_name, table_name, lower_bound, upper_bound) def create_range_partition_safely(partition_name, table_name, lower_bound, upper_bound)
if table_exists?(table_for_range_partition(partition_name)) if table_exists?(table_for_range_partition(partition_name))
# rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn "Partition not created because it already exists" \
Rails.logger.warn "Partition not created because it already exists" \
" (this may be due to an aborted migration or similar): partition_name: #{partition_name}" " (this may be due to an aborted migration or similar): partition_name: #{partition_name}"
# rubocop:enable Gitlab/RailsLogger
return return
end end
...@@ -282,10 +278,8 @@ module Gitlab ...@@ -282,10 +278,8 @@ module Gitlab
def create_sync_function(name, partitioned_table_name, unique_key) def create_sync_function(name, partitioned_table_name, unique_key)
if function_exists?(name) if function_exists?(name)
# rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn "Partitioning sync function not created because it already exists" \
Rails.logger.warn "Partitioning sync function not created because it already exists" \
" (this may be due to an aborted migration or similar): function name: #{name}" " (this may be due to an aborted migration or similar): function name: #{name}"
# rubocop:enable Gitlab/RailsLogger
return return
end end
...@@ -317,10 +311,8 @@ module Gitlab ...@@ -317,10 +311,8 @@ module Gitlab
def create_sync_trigger(table_name, trigger_name, function_name) def create_sync_trigger(table_name, trigger_name, function_name)
if trigger_exists?(table_name, trigger_name) if trigger_exists?(table_name, trigger_name)
# rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.warn "Partitioning sync trigger not created because it already exists" \
Rails.logger.warn "Partitioning sync trigger not created because it already exists" \
" (this may be due to an aborted migration or similar): trigger name: #{trigger_name}" " (this may be due to an aborted migration or similar): trigger name: #{trigger_name}"
# rubocop:enable Gitlab/RailsLogger
return return
end end
......
...@@ -71,7 +71,7 @@ module Gitlab ...@@ -71,7 +71,7 @@ module Gitlab
unless gitlab_shell.mv_namespace(repository_storage, old_full_path, new_full_path) unless gitlab_shell.mv_namespace(repository_storage, old_full_path, new_full_path)
message = "Exception moving on shard #{repository_storage} from #{old_full_path} to #{new_full_path}" message = "Exception moving on shard #{repository_storage} from #{old_full_path} to #{new_full_path}"
Rails.logger.error message # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.error message
end end
end end
end end
......
...@@ -56,7 +56,7 @@ module Gitlab ...@@ -56,7 +56,7 @@ module Gitlab
unless gitlab_shell.mv_repository(project.repository_storage, unless gitlab_shell.mv_repository(project.repository_storage,
old_path, old_path,
new_path) new_path)
Rails.logger.error "Error moving #{old_path} to #{new_path}" # rubocop:disable Gitlab/RailsLogger Gitlab::AppLogger.error "Error moving #{old_path} to #{new_path}"
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment