FIX: update Redis gem to version 4.1.3

FIX: update Redis gem to version 4.1.3

I run our benchmark on commit with hiredis and redis-4.1.3

Results:

type hidredis redis 4.1.3 percent
Categories-50 49 50 102.04%
Categories-75 51 51 100.00%
Categories-90 63 64 101.59%
Categories-99 86 85 98.84%
Home-50 55 55 100.00%
Home-75 56 57 101.79%
Home-90 68 69 101.47%
Home-99 102 104 101.96%
Topic-50 36 37 102.78%
Topic-75 37 37 100.00%
Topic-90 47 48 102.13%
Topic-99 60 61 101.67%
Categories-admin-50 124 117 94.35%
Categories-admin-75 130 129 99.23%
Categories-admin-90 147 143 97.28%
Categories-admin-99 204 199 97.55%
Home-admin-50 146 148 101.37%
Home-admin-75 150 152 101.33%
Home-admin-90 169 168 99.41%
Home-admin-99 232 223 96.12%
Topic-admin-50 60 61 101.67%
Topic-admin-75 64 63 98.44%
Topic-admin-90 76 73 96.05%
Topic-admin-99 124 94 75.81%
Load rails 2412 2360 97.84%
rss 290204 295828 101.94%
pss 277948 283624 102.04%

Redis gem is manipulating Redis config redis-rb/client.rb at master · redis/redis-rb · GitHub therefore we cannot pass the frozen config object.

Pass of the copy of the object is protecting original config

diff --git a/Gemfile b/Gemfile
index d523170a4e..8f032801eb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -36,14 +36,7 @@ gem 'mail', require: false
 gem 'mini_mime'
 gem 'mini_suffix'
 
-# holding off redis upgrade temporarily as it is having issues with our current
-# freedom patch, we will follow this up.
-#
-# FrozenError: can't modify frozen Hash
-# /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/redis-4.1.0/lib/redis/client.rb:93:in `delete'
-# /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/redis-4.1.0/lib/redis/client.rb:93:in `initialize'
-# /var/www/discourse/lib/freedom_patches/redis.rb:7:in `initialize'
-gem 'redis', '4.0.1'
+gem 'redis', '4.1.3'
 gem 'redis-namespace'
 
 gem 'active_model_serializers', '~> 0.8.3'
diff --git a/Gemfile.lock b/Gemfile.lock
index f58c26a167..b43335ea81 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -182,7 +182,7 @@ GEM
       mini_mime (>= 0.1.1)
     maxminddb (0.1.22)
     memory_profiler (0.9.13)
-    message_bus (2.2.2)
+    message_bus (2.2.3)
       rack (>= 1.1.3)
     metaclass (0.0.4)
     method_source (0.9.2)
@@ -309,7 +309,7 @@ GEM
       msgpack (>= 0.4.3)
       optimist (>= 3.0.0)
     rchardet (1.8.0)
-    redis (4.0.1)
+    redis (4.1.3)
     redis-namespace (1.6.0)
       redis (>= 3.0.4)
     request_store (1.4.1)
@@ -516,7 +516,7 @@ DEPENDENCIES
   rb-inotify (~> 0.9)
   rbtrace
   rchardet
-  redis (= 4.0.1)
+  redis (= 4.1.3)
   redis-namespace
   rinku
   rotp
diff --git a/config/application.rb b/config/application.rb
index dd56bf859f..a8f2fcc98f 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -241,7 +241,6 @@ module Discourse
 
     require 'discourse_redis'
     require 'logster/redis_store'
-    require 'freedom_patches/redis'
     # Use redis for our cache
     config.cache_store = DiscourseRedis.new_redis_store
     $redis = DiscourseRedis.new
diff --git a/lib/discourse_redis.rb b/lib/discourse_redis.rb
index 89e588806f..ae2884f933 100644
--- a/lib/discourse_redis.rb
+++ b/lib/discourse_redis.rb
@@ -155,7 +155,7 @@ class DiscourseRedis
 
   def initialize(config = nil, namespace: true)
     @config = config || DiscourseRedis.config
-    @redis = DiscourseRedis.raw_connection(@config)
+    @redis = DiscourseRedis.raw_connection(@config.dup)
     @namespace = namespace
   end
 
diff --git a/lib/freedom_patches/redis.rb b/lib/freedom_patches/redis.rb
deleted file mode 100644
index 8945ece473..0000000000
--- a/lib/freedom_patches/redis.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-# https://github.com/redis/redis-rb/pull/591
-class Redis
-  class Client
-    alias_method :old_initialize, :initialize
-
-    def initialize(options = {})
-      old_initialize(options)
-
-      if options.include?(:connector) && options[:connector].is_a?(Class)
-        @connector = options[:connector].new(@options)
-      end
-    end
-  end
-end

GitHub sha: 858cf583

3 Likes

Overall looks similar to me. Sounds good.