mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Warn on boot if maxmemory policy is not 'noeviction' (#4752)
This commit is contained in:
parent
622adfe6c6
commit
c4c01f8894
2 changed files with 31 additions and 0 deletions
|
@ -62,6 +62,11 @@ module Sidekiq
|
||||||
ver = Sidekiq.redis_info["redis_version"]
|
ver = Sidekiq.redis_info["redis_version"]
|
||||||
raise "You are connecting to Redis v#{ver}, Sidekiq requires Redis v4.0.0 or greater" if ver < "4"
|
raise "You are connecting to Redis v#{ver}, Sidekiq requires Redis v4.0.0 or greater" if ver < "4"
|
||||||
|
|
||||||
|
maxmemory_policy = Sidekiq.redis_info["maxmemory_policy"]
|
||||||
|
if maxmemory_policy != "noeviction"
|
||||||
|
logger.warn "'noeviction' maxmemory policy is recommended (current policy: '#{maxmemory_policy}'). See: https://github.com/mperham/sidekiq/wiki/Using-Redis#memory"
|
||||||
|
end
|
||||||
|
|
||||||
# Since the user can pass us a connection pool explicitly in the initializer, we
|
# Since the user can pass us a connection pool explicitly in the initializer, we
|
||||||
# need to verify the size is large enough or else Sidekiq's performance is dramatically slowed.
|
# need to verify the size is large enough or else Sidekiq's performance is dramatically slowed.
|
||||||
cursize = Sidekiq.redis_pool.size
|
cursize = Sidekiq.redis_pool.size
|
||||||
|
|
|
@ -481,6 +481,32 @@ describe Sidekiq::CLI do
|
||||||
assert_includes @logdev.string, "Booted Rails #{::Rails.version} application in production environment"
|
assert_includes @logdev.string, "Booted Rails #{::Rails.version} application in production environment"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'checking maxmemory policy' do
|
||||||
|
it 'warns if the policy is not noeviction' do
|
||||||
|
redis_info = { "maxmemory_policy" => "allkeys-lru", "redis_version" => "6" }
|
||||||
|
|
||||||
|
Sidekiq.stub(:redis_info, redis_info) do
|
||||||
|
subject.stub(:launch, nil) do
|
||||||
|
subject.run
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_includes @logdev.string, "'noeviction' maxmemory policy is recommended (current policy: 'allkeys-lru')"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'silent if the policy is noeviction' do
|
||||||
|
redis_info = { "maxmemory_policy" => "noeviction", "redis_version" => "6" }
|
||||||
|
|
||||||
|
Sidekiq.stub(:redis_info, redis_info) do
|
||||||
|
subject.stub(:launch, nil) do
|
||||||
|
subject.run
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
refute_includes @logdev.string, "'noeviction' maxmemory policy is recommended"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'signal handling' do
|
describe 'signal handling' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue