Skip to content

Commit

Permalink
Merge pull request #1535 from S-H-GAMELINKS/update/sidekiq-7.3.2
Browse files Browse the repository at this point in the history
Update Sidekiq v7.3.2
  • Loading branch information
S-H-GAMELINKS authored Oct 18, 2024
2 parents 23bc411 + 1b969a6 commit 58e586f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
rspec-persistence-main
rspec-persistence
- run: bin/flatware rspec -r ./spec/flatware_helper.rb
- run: bin/rspec

- name: Upload coverage reports to Codecov
if: matrix.ruby-version == '.ruby-version'
Expand Down
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ gem 'doorkeeper', '~> 5.6'
gem 'fast_blank', '~> 1.0'
gem 'fastimage'
gem 'hiredis', '~> 0.6'
gem 'hiredis-client'
gem 'htmlentities', '~> 4.3'
gem 'http', '~> 5.2.0'
gem 'http_accept_language', '~> 2.1'
Expand Down Expand Up @@ -79,10 +80,10 @@ gem 'rqrcode', '~> 2.2'
gem 'ruby-progressbar', '~> 1.13'
gem 'sanitize', '~> 6.0'
gem 'scenic', '~> 1.7'
gem 'sidekiq', '~> 6.5'
gem 'sidekiq', '~> 7.3'
gem 'sidekiq-bulk', '~> 0.2.0'
gem 'sidekiq-scheduler', '~> 5.0'
gem 'sidekiq-unique-jobs', '~> 7.1'
gem 'sidekiq-scheduler', '~> 5.0', '>= 5.0.6'
gem 'sidekiq-unique-jobs', '~> 8.0', '>= 8.0.10'
gem 'simple_form', '~> 5.2'
gem 'simple-navigation', '~> 4.4'
gem 'stoplight', '~> 4.1'
Expand Down
32 changes: 17 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ GEM
brakeman (6.2.1)
racc
browser (5.3.1)
brpoplpush-redis_script (0.1.3)
concurrent-ruby (~> 1.0, >= 1.0.5)
redis (>= 1.0, < 6)
builder (3.3.0)
bundler-audit (0.9.2)
bundler (>= 1.2.0, < 3)
Expand Down Expand Up @@ -342,6 +339,8 @@ GEM
highline (3.1.1)
reline
hiredis (0.6.3)
hiredis-client (0.22.2)
redis-client (= 0.22.2)
hkdf (0.3.0)
htmlentities (4.3.4)
http (5.2.0)
Expand Down Expand Up @@ -728,6 +727,8 @@ GEM
psych (>= 4.0.0)
redcarpet (3.6.0)
redis (4.8.1)
redis-client (0.22.2)
connection_pool
redis-namespace (1.11.0)
redis (>= 4)
redlock (1.3.2)
Expand Down Expand Up @@ -835,22 +836,22 @@ GEM
semantic_range (3.0.0)
shoulda-matchers (6.4.0)
activesupport (>= 5.2.0)
sidekiq (6.5.12)
connection_pool (>= 2.2.5, < 3)
rack (~> 2.0)
redis (>= 4.5.0, < 5)
sidekiq (7.3.2)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
sidekiq-bulk (0.2.0)
sidekiq
sidekiq-scheduler (5.0.6)
rufus-scheduler (~> 3.2)
sidekiq (>= 6, < 8)
tilt (>= 1.4.0, < 3)
sidekiq-unique-jobs (7.1.33)
brpoplpush-redis_script (> 0.1.1, <= 2.0.0)
sidekiq-unique-jobs (8.0.10)
concurrent-ruby (~> 1.0, >= 1.0.5)
redis (< 5.0)
sidekiq (>= 5.0, < 7.0)
thor (>= 0.20, < 3.0)
sidekiq (>= 7.0.0, < 8.0.0)
thor (>= 1.0, < 3.0)
simple-navigation (4.4.0)
activesupport (>= 2.3.2)
simple_form (5.3.1)
Expand Down Expand Up @@ -1013,6 +1014,7 @@ DEPENDENCIES
haml_lint
hcaptcha (~> 7.1)
hiredis (~> 0.6)
hiredis-client
htmlentities (~> 4.3)
http (~> 5.2.0)
http_accept_language (~> 2.1)
Expand Down Expand Up @@ -1106,10 +1108,10 @@ DEPENDENCIES
scenic (~> 1.7)
selenium-webdriver
shoulda-matchers
sidekiq (~> 6.5)
sidekiq (~> 7.3)
sidekiq-bulk (~> 0.2.0)
sidekiq-scheduler (~> 5.0)
sidekiq-unique-jobs (~> 7.1)
sidekiq-scheduler (~> 5.0, >= 5.0.6)
sidekiq-unique-jobs (~> 8.0, >= 8.0.10)
simple-navigation (~> 4.4)
simple_form (~> 5.2)
simplecov (~> 0.22)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/redis_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def pool

def pool_size
if Sidekiq.server?
Sidekiq[:concurrency]
Sidekiq.default_configuration.concurrency
else
ENV['MAX_THREADS'] || 5
end
Expand Down
2 changes: 1 addition & 1 deletion app/workers/scheduler/self_destruct_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def perform
private

def sidekiq_overwhelmed?
redis_mem_info = Sidekiq.redis_info
redis_mem_info = Sidekiq.default_configuration.redis_info

Sidekiq::Stats.new.enqueued > MAX_ENQUEUED || redis_mem_info['used_memory'].to_f > redis_mem_info['total_system_memory'].to_f * MAX_REDIS_MEM_USAGE
end
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default: &default
adapter: postgresql
pool: <%= ENV["DB_POOL"] || (if Sidekiq.server? then Sidekiq[:concurrency] else ENV['MAX_THREADS'] end) || 5 %>
pool: <%= ENV["DB_POOL"] || (if Sidekiq.server? then Sidekiq.default_configuration.concurrency else ENV['MAX_THREADS'] end) || 5 %>
timeout: 5000
connect_timeout: 15
encoding: unicode
Expand Down
21 changes: 0 additions & 21 deletions lib/mastodon/redis_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ class Mastodon::RedisConfiguration

def base
@base ||= setup_config(prefix: nil, defaults: DEFAULTS)
.merge(namespace: base_namespace)
end

def sidekiq
@sidekiq ||= setup_config(prefix: 'SIDEKIQ_')
.merge(namespace: sidekiq_namespace)
end

def cache
@cache ||= setup_config(prefix: 'CACHE_')
.merge({
namespace: cache_namespace,
expires_in: 10.minutes,
connect_timeout: 5,
pool: {
Expand All @@ -36,24 +33,6 @@ def driver
ENV['REDIS_DRIVER'] == 'ruby' ? :ruby : :hiredis
end

def namespace
@namespace ||= ENV.fetch('REDIS_NAMESPACE', nil)
end

def base_namespace
return "mastodon_test#{ENV.fetch('TEST_ENV_NUMBER', nil)}" if Rails.env.test?

namespace
end

def sidekiq_namespace
namespace
end

def cache_namespace
namespace ? "#{namespace}_cache" : 'cache'
end

def setup_config(prefix: nil, defaults: {})
prefix = "#{prefix}REDIS_"

Expand Down
38 changes: 0 additions & 38 deletions spec/lib/mastodon/redis_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@
end
end

shared_examples 'setting a namespace' do
context 'when setting the `REDIS_NAMESPACE` variable' do
around do |example|
ClimateControl.modify REDIS_NAMESPACE: 'testns' do
example.run
end
end

it 'uses the value for the namespace' do
expect(subject[:namespace]).to eq 'testns'
end
end
end

shared_examples 'secondary configuration' do |prefix|
context "when no `#{prefix}_REDIS_` environment variables are present" do
it 'uses the url from the base config' do
Expand Down Expand Up @@ -170,7 +156,6 @@
expect(subject).to eq({
url: 'redis://localhost:6379/0',
driver: :hiredis,
namespace: nil,
})
end
end
Expand All @@ -186,7 +171,6 @@
expect(subject).to eq({
url: 'redis::/[email protected]/2',
driver: :hiredis,
namespace: nil,
})
end
end
Expand All @@ -202,13 +186,11 @@
expect(subject).to eq({
url: 'redis://:[email protected]:3333/3',
driver: :hiredis,
namespace: nil,
})
end
end

include_examples 'setting a different driver'
include_examples 'setting a namespace'
include_examples 'sentinel support'
end

Expand All @@ -217,7 +199,6 @@

include_examples 'secondary configuration', 'SIDEKIQ'
include_examples 'setting a different driver'
include_examples 'setting a namespace'
include_examples 'sentinel support', 'SIDEKIQ'
end

Expand All @@ -228,7 +209,6 @@
expect(subject).to eq({
url: 'redis://localhost:6379/0',
driver: :hiredis,
namespace: 'cache',
expires_in: 10.minutes,
connect_timeout: 5,
pool: {
Expand All @@ -238,24 +218,6 @@
})
end

context 'when `REDIS_NAMESPACE` is not set' do
it 'uses the `cache` namespace' do
expect(subject[:namespace]).to eq 'cache'
end
end

context 'when setting the `REDIS_NAMESPACE` variable' do
around do |example|
ClimateControl.modify REDIS_NAMESPACE: 'testns' do
example.run
end
end

it 'attaches the `_cache` postfix to the namespace' do
expect(subject[:namespace]).to eq 'testns_cache'
end
end

include_examples 'secondary configuration', 'CACHE'
include_examples 'setting a different driver'
include_examples 'sentinel support', 'CACHE'
Expand Down
4 changes: 3 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
allow_localhost: true,
allow: Chewy.settings[:host]
)
Sidekiq.logger = nil
Sidekiq.configure_server do |cfg|
cfg.logger = nil
end

DatabaseCleaner.strategy = [:deletion]

Expand Down

0 comments on commit 58e586f

Please sign in to comment.