From ab6af06974f5eaaf5582a2899612b778ce077d54 Mon Sep 17 00:00:00 2001 From: Patrick Cyiza <jpcyiza@gitlab.com> Date: Mon, 31 Jul 2023 15:00:28 +0000 Subject: [PATCH] Disable redis pool because we already implemented it A better option is to correctly propagate pool options to Rails instead of wrapping our Redis clients into connection pools --- lib/gitlab/redis/cache.rb | 5 +++++ lib/gitlab/redis/feature_flag.rb | 1 + lib/gitlab/redis/repository_cache.rb | 1 + spec/lib/gitlab/redis/cache_spec.rb | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/lib/gitlab/redis/cache.rb b/lib/gitlab/redis/cache.rb index 60944268f91e..6121555e4359 100644 --- a/lib/gitlab/redis/cache.rb +++ b/lib/gitlab/redis/cache.rb @@ -8,9 +8,14 @@ class Cache < ::Gitlab::Redis::Wrapper class << self # Full list of options: # https://api.rubyonrails.org/classes/ActiveSupport/Cache/RedisCacheStore.html#method-c-new + # pool argument event not documented in the link above is handled by RedisCacheStore see: + # https://github.com/rails/rails/blob/593893c901f87b4ed205751f72df41519b4d2da3/activesupport/lib/active_support/cache/redis_cache_store.rb#L165 + # and + # https://github.com/rails/rails/blob/ad790cb2f6bc724a89e4266b505b3c57d5089dae/activesupport/lib/active_support/cache.rb#L206 def active_support_config { redis: pool, + pool: false, compress: Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1')), namespace: CACHE_NAMESPACE, expires_in: default_ttl_seconds diff --git a/lib/gitlab/redis/feature_flag.rb b/lib/gitlab/redis/feature_flag.rb index 441ff6690350..395805792d73 100644 --- a/lib/gitlab/redis/feature_flag.rb +++ b/lib/gitlab/redis/feature_flag.rb @@ -14,6 +14,7 @@ def config_fallback def cache_store @cache_store ||= FeatureFlagStore.new( redis: pool, + pool: false, compress: Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1')), namespace: Cache::CACHE_NAMESPACE, expires_in: 1.hour diff --git a/lib/gitlab/redis/repository_cache.rb b/lib/gitlab/redis/repository_cache.rb index 966c6584aa55..6d0c35a68294 100644 --- a/lib/gitlab/redis/repository_cache.rb +++ b/lib/gitlab/redis/repository_cache.rb @@ -15,6 +15,7 @@ def config_fallback def cache_store @cache_store ||= RepositoryCacheStore.new( redis: pool, + pool: false, compress: Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1')), namespace: Cache::CACHE_NAMESPACE, expires_in: Cache.default_ttl_seconds diff --git a/spec/lib/gitlab/redis/cache_spec.rb b/spec/lib/gitlab/redis/cache_spec.rb index b7b4ba0eb2f4..a48bde5e4ab9 100644 --- a/spec/lib/gitlab/redis/cache_spec.rb +++ b/spec/lib/gitlab/redis/cache_spec.rb @@ -17,5 +17,9 @@ expect(described_class.active_support_config[:expires_in]).to eq(1.day) end + + it 'has a pool set to false' do + expect(described_class.active_support_config[:pool]).to eq(false) + end end end -- GitLab