diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-25 12:18:56 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-25 12:18:56 +0000 |
commit | d2d913b606702ecefa01f03362602fde256e3f75 (patch) | |
tree | 07643306ee63f789188a9133823aac3c92c94dfb /config/initializers | |
parent | af69e63b6655a450849a8fa2640ae6ce5a8db681 (diff) | |
download | gitlab-ce-d2d913b606702ecefa01f03362602fde256e3f75.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/active_record_transaction_observer.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/config/initializers/active_record_transaction_observer.rb b/config/initializers/active_record_transaction_observer.rb index 1dc7b55ed5a..a133c6b8be8 100644 --- a/config/initializers/active_record_transaction_observer.rb +++ b/config/initializers/active_record_transaction_observer.rb @@ -3,7 +3,20 @@ return unless Gitlab.com? || Gitlab.dev_or_test_env? Gitlab::Application.configure do - if Feature.feature_flags_available? && ::Feature.enabled?(:active_record_transactions_tracking, type: :ops) + # When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised + active_db_connection = begin + ActiveRecord::Base.connection.active? # rubocop:disable Database/MultipleDatabases + rescue StandardError + false + end + + feature_flags_available = begin + active_db_connection && Feature::FlipperFeature.table_exists? + rescue ActiveRecord::NoDatabaseError + false + end + + if feature_flags_available && ::Feature.enabled?(:active_record_transactions_tracking, type: :ops) Gitlab::Database::Transaction::Observer.register! end end |