diff options
author | Stan Hu <stanhu@gmail.com> | 2016-06-30 01:14:06 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-06-30 01:14:06 +0300 |
commit | f7eceed64483ecc831156d2ab2541a6793e92868 (patch) | |
tree | 8b2bff9591279de1c89289f85b03b91a09254a16 /lib | |
parent | 65187efa5c7202e8b6429edfd17ad844cd584a32 (diff) | |
parent | d10642a4b86d91faf7a3ffa508b4e8067213b14c (diff) |
Merge branch 'handle-redis-not-there' into 'master'
Fix database migrations when Redis is not running
If Redis were not running or USE_DB were set to false, the application settings retrieval would fail completely. This change only attempts to use the cache if the system actually
wants to connect to the DB and rescues any failures in talking to Redis.
Closes #17557
See merge request !4924
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/current_settings.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 28c34429c1f..54b46e5d23f 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -9,10 +9,14 @@ module Gitlab end def ensure_application_settings! - settings = ::ApplicationSetting.cached + if connect_to_db? + begin + settings = ::ApplicationSetting.current + # In case Redis isn't running or the Redis UNIX socket file is not available + rescue ::Redis::BaseError, ::Errno::ENOENT + settings = ::ApplicationSetting.last + end - if !settings && connect_to_db? - settings = ::ApplicationSetting.current settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration? end |