diff --git a/Changes.md b/Changes.md index 99536ace..8f7d8e76 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ HEAD --------- +- Warn if Redis is configured to evict data under memory pressure [#4752] - Add process RSS on the Busy page [#4717] 6.1.2 diff --git a/lib/sidekiq/cli.rb b/lib/sidekiq/cli.rb index 5b836135..df6339a6 100644 --- a/lib/sidekiq/cli.rb +++ b/lib/sidekiq/cli.rb @@ -59,12 +59,20 @@ module Sidekiq # touch the connection pool so it is created before we # fire startup and start multithreading. - ver = Sidekiq.redis_info["redis_version"] + info = Sidekiq.redis_info + ver = info["redis_version"] 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"] + maxmemory_policy = 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" + logger.warn <<~EOM + + + WARNING: Your Redis instance will evict Sidekiq data under heavy load. + The 'noeviction' maxmemory policy is recommended (current policy: '#{maxmemory_policy}'). + See: https://github.com/mperham/sidekiq/wiki/Using-Redis#memory + + EOM end # Since the user can pass us a connection pool explicitly in the initializer, we diff --git a/test/test_cli.rb b/test/test_cli.rb index 716ae32f..959b0380 100644 --- a/test/test_cli.rb +++ b/test/test_cli.rb @@ -492,7 +492,7 @@ describe Sidekiq::CLI do end end - assert_includes @logdev.string, "'noeviction' maxmemory policy is recommended (current policy: 'allkeys-lru')" + assert_includes @logdev.string, "allkeys-lru" end it 'silent if the policy is noeviction' do @@ -504,7 +504,7 @@ describe Sidekiq::CLI do end end - refute_includes @logdev.string, "'noeviction' maxmemory policy is recommended" + refute_includes @logdev.string, "noeviction" end end end