From b1bdaa7859b3b671db8ff9490c5b9f3d955acf22 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Tue, 7 Aug 2018 08:17:59 -0700 Subject: [PATCH] Verify connection pool sizing, fixes #3917 --- Changes.md | 1 + lib/sidekiq/cli.rb | 6 ++++++ sidekiq.gemspec | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Changes.md b/Changes.md index aa324f04..0a830172 100644 --- a/Changes.md +++ b/Changes.md @@ -6,6 +6,7 @@ HEAD ----------- - **Decrease default concurrency from 25 to 10** [#3892] +- Verify connection pool sizing upon startup [#3917] - Smoother scheduling for large Sidekiq clusters [#3889] - Switch Sidekiq::Testing impl from alias\_method to Module#prepend, for resiliency [#3852] - Update Sidekiq APIs to use SCAN for scalability [#3848, ffiller] diff --git a/lib/sidekiq/cli.rb b/lib/sidekiq/cli.rb index c4b70866..61eee6b5 100644 --- a/lib/sidekiq/cli.rb +++ b/lib/sidekiq/cli.rb @@ -80,6 +80,12 @@ module Sidekiq ver = Sidekiq.redis_info['redis_version'] raise "You are using Redis v#{ver}, Sidekiq requires Redis v2.8.0 or greater" if ver < '2.8' + # 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. + cursize = Sidekiq.redis_pool.size + needed = Sidekiq.options[:concurrency] + 2 + raise "Your pool of #{cursize} Redis connections is too small, please increase the size to at least #{needed}" if cursize < needed + # cache process identity Sidekiq.options[:identity] = identity diff --git a/sidekiq.gemspec b/sidekiq.gemspec index 179a9f2e..797ddc75 100644 --- a/sidekiq.gemspec +++ b/sidekiq.gemspec @@ -18,6 +18,6 @@ Gem::Specification.new do |gem| gem.required_ruby_version = ">= 2.2.2" gem.add_dependency 'redis', '>= 3.3.5', '< 5' - gem.add_dependency 'connection_pool', '~> 2.2', '>= 2.2.0' + gem.add_dependency 'connection_pool', '~> 2.2', '>= 2.2.2' gem.add_dependency 'rack-protection', '>= 1.5.0' end