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 https://github.com/redis/redis-rb/blob/master/lib/redis/client.rb#L95
therefore we cannot pass the frozen config object.

Pass of the copy of the object is protecting original config
This commit is contained in:
Krzysztof Kotlarek 2019-10-21 09:59:24 +11:00 committed by GitHub
parent 054fbd7846
commit 858cf5836c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 29 deletions

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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