diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-13 06:10:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-13 06:10:09 +0300 |
commit | ed01bf9b255ebcaafdf07e0d9a54ce6886d9fdc7 (patch) | |
tree | ff197d19fc9f99effbdd837f7a911fa8f322c557 /config | |
parent | 2023b1313d8f42bff1d6563330c0a7eed9d4dd85 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config')
4 files changed, 37 insertions, 3 deletions
diff --git a/config/feature_flags/ops/active_record_transactions_tracking.yml b/config/feature_flags/ops/active_record_transactions_tracking.yml new file mode 100644 index 00000000000..37bc76b3cf8 --- /dev/null +++ b/config/feature_flags/ops/active_record_transactions_tracking.yml @@ -0,0 +1,8 @@ +--- +name: active_record_transactions_tracking +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67918 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338306 +milestone: '14.2' +type: ops +group: group::pipeline execution +default_enabled: false diff --git a/config/initializers/active_record_transaction_observer.rb b/config/initializers/active_record_transaction_observer.rb new file mode 100644 index 00000000000..fc9b73d656e --- /dev/null +++ b/config/initializers/active_record_transaction_observer.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +return unless Gitlab.com? || Gitlab.dev_or_test_env? + +def feature_flags_available? + # When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised + active_db_connection = ActiveRecord::Base.connection.active? rescue false + + active_db_connection && Feature::FlipperFeature.table_exists? +rescue ActiveRecord::NoDatabaseError + false +end + +Gitlab::Application.configure do + if feature_flags_available? && ::Feature.enabled?(:active_record_transactions_tracking, type: :ops, default_enabled: :yaml) + Gitlab::Database::Transaction::Observer.register! + end +end diff --git a/config/initializers/active_record_transaction_patches.rb b/config/initializers/active_record_transaction_patches.rb new file mode 100644 index 00000000000..bf92ec73c80 --- /dev/null +++ b/config/initializers/active_record_transaction_patches.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +if ENV['ACTIVE_RECORD_DISABLE_TRANSACTION_METRICS_PATCHES'].blank? + Gitlab::Database.install_transaction_metrics_patches! +end + +return unless Gitlab.com? || Gitlab.dev_or_test_env? + +if ENV['ACTIVE_RECORD_DISABLE_TRANSACTION_CONTEXT_PATCHES'].blank? + Gitlab::Database.install_transaction_context_patches! +end diff --git a/config/initializers/transaction_metrics.rb b/config/initializers/transaction_metrics.rb deleted file mode 100644 index 0175d487e66..00000000000 --- a/config/initializers/transaction_metrics.rb +++ /dev/null @@ -1,3 +0,0 @@ -# frozen_string_literal: true - -Gitlab::Database.install_monkey_patches |