Revert "FIX: update Redis gem to version 4.1.3 (#8197)"

Revert “FIX: update Redis gem to version 4.1.3 (#8197)”

This reverts commit ab74a50d857c6a0ac7e5c11f9d8ddd12ee5e1805.

We really want to upgrade redis, but discovered some edge cases around failover we need to test.

Holding off on the upgrade till a bit more testing happens

diff --git a/Gemfile b/Gemfile
index 8f032801eb..d523170a4e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -36,7 +36,14 @@ gem 'mail', require: false
 gem 'mini_mime'
 gem 'mini_suffix'
 
-gem 'redis', '4.1.3'
+# 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-namespace'
 
 gem 'active_model_serializers', '~> 0.8.3'
diff --git a/Gemfile.lock b/Gemfile.lock
index bd215e663e..d54d718a12 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -309,7 +309,7 @@ GEM
       msgpack (>= 0.4.3)
       optimist (>= 3.0.0)
     rchardet (1.8.0)
-    redis (4.1.3)
+    redis (4.0.1)
     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.1.3)
+  redis (= 4.0.1)
   redis-namespace
   rinku
   rotp
diff --git a/config/application.rb b/config/application.rb
index a8f2fcc98f..dd56bf859f 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -241,6 +241,7 @@ 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/freedom_patches/redis.rb b/lib/freedom_patches/redis.rb
new file mode 100644
index 0000000000..8945ece473
--- /dev/null
+++ b/lib/freedom_patches/redis.rb
@@ -0,0 +1,16 @@
+# 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: ae2a5699