Skip to content
Snippets Groups Projects
Verified Commit c68bc2d1 authored by Sylvester Chin's avatar Sylvester Chin :red_circle: Committed by GitLab
Browse files

Fix failing lint and test

parent 7c983da4
No related branches found
No related tags found
1 merge request!163593Bump vendored Sidekiq gem to 7.2.4
Showing
with 607 additions and 28 deletions
......@@ -53,5 +53,5 @@ include:
gem_path_prefix: "vendor/gems/"
- local: .gitlab/ci/templates/gem.gitlab-ci.yml
inputs:
gem_name: "sidekiq-7.1.6"
gem_name: "sidekiq-7.2.4"
gem_path_prefix: "vendor/gems/"
......@@ -279,7 +279,7 @@ end
gem 'state_machines-activerecord', '~> 0.8.0' # rubocop:todo Gemfile/MissingFeatureCategory
# Background jobs
gem 'sidekiq', path: 'vendor/gems/sidekiq-7.1.6', require: 'sidekiq', feature_category: :scalability
gem 'sidekiq', path: 'vendor/gems/sidekiq-7.2.4', require: 'sidekiq', feature_category: :scalability
gem 'sidekiq-cron', '~> 1.12.0', feature_category: :scalability
gem 'gitlab-sidekiq-fetcher',
path: 'vendor/gems/sidekiq-reliable-fetch',
......
......@@ -194,13 +194,13 @@ PATH
omniauth (~> 2.0)
PATH
remote: vendor/gems/sidekiq-7.1.6
remote: vendor/gems/sidekiq-7.2.4
specs:
sidekiq (7.1.6)
sidekiq (7.2.4)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.14.0)
redis-client (>= 0.19.0)
PATH
remote: vendor/gems/sidekiq-reliable-fetch
......
......@@ -194,13 +194,13 @@ PATH
omniauth (~> 2.0)
PATH
remote: vendor/gems/sidekiq-7.1.6
remote: vendor/gems/sidekiq-7.2.4
specs:
sidekiq (7.1.6)
sidekiq (7.2.4)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.14.0)
redis-client (>= 0.19.0)
PATH
remote: vendor/gems/sidekiq-reliable-fetch
......
......@@ -38,7 +38,7 @@ def load_cron_jobs!
Sidekiq.strict_args!(strict_args_mode)
# Perform version check before configuring server with the custome scheduled job enqueue class
unless Gem::Version.new(Sidekiq::VERSION) == Gem::Version.new('7.1.6')
unless Gem::Version.new(Sidekiq::VERSION) == Gem::Version.new('7.2.4')
raise 'New version of Sidekiq detected, please either update the version for this check ' \
'and update Gitlab::SidekiqSharding::ScheduledEnq is compatible.'
end
......
......@@ -7,7 +7,7 @@
require 'sidekiq/version'
require 'sidekiq/cron/version'
if Gem::Version.new(Sidekiq::VERSION) != Gem::Version.new('7.1.6')
if Gem::Version.new(Sidekiq::VERSION) != Gem::Version.new('7.2.4')
raise 'New version of sidekiq detected, please remove or update this patch'
end
......
# frozen_string_literal: true
if Gem::Version.new(Sidekiq::VERSION) != Gem::Version.new('7.1.6')
if Gem::Version.new(Sidekiq::VERSION) != Gem::Version.new('7.2.4')
raise 'New version of sidekiq detected, please remove or update this patch'
end
......
......@@ -45,6 +45,14 @@ def enabled
end
end
Sidekiq::RedisClientAdapter::CompatMethods::USED_COMMANDS.each do |name|
define_method(name) do |*args, **kwargs|
validate! if Thread.current[:validate_sidekiq_shard_awareness]
super(*args, **kwargs)
end
end
# This is used to patch the Sidekiq::RedisClientAdapter to validate all Redis commands are routed
# rubocop:disable Style/MissingRespondToMissing -- already defined in the module we are patching
def method_missing(*args, &block)
......
<div class="sm-col-3 pull-right" style="display: inline; margin: 25px 15px 0 0;">
<%= t('Filter') %>:
<form method="POST" action='<%= root_path %>filter/<%= which %>' style="display: inline-block">
<%= csrf_tag %>
<input class="search" type="search" name="substr" value="<%= h params[:substr] %>" placeholder="<%= t('AnyJobContent') %>"/>
</form>
</div>
include:
- local: gems/gem.gitlab-ci.yml
inputs:
gem_name: "sidekiq-7.1.6"
gem_name: "sidekiq-7.2.4"
gem_path_prefix: "vendor/gems/"
rspec:
......
......@@ -2,6 +2,69 @@
[Sidekiq Changes](https://github.com/sidekiq/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/sidekiq/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/sidekiq/sidekiq/blob/main/Ent-Changes.md)
7.2.4
----------
- Fix XSS in metrics filtering introduced in 7.2.0, CVE-2024-32887
Thanks to @UmerAdeemCheema for the security report.
7.2.3
----------
- [Support Dragonfly.io](https://www.mikeperham.com/2024/02/01/supporting-dragonfly/) as an alternative Redis implementation
- Fix error unpacking some compressed error backtraces [#6241]
- Fix potential heartbeat data leak [#6227]
- Add ability to find a currently running work by jid [#6212, fatkodima]
7.2.2
----------
- Add `Process.warmup` call in Ruby 3.3+
- Batch jobs now skip transactional push [#6160]
7.2.1
----------
- Add `Sidekiq::Work` type which replaces the raw Hash as the third parameter in
`Sidekiq::WorkSet#each { |pid, tid, hash| ... }` [#6145]
- **DEPRECATED**: direct access to the attributes within the `hash` block parameter above.
The `Sidekiq::Work` instance contains accessor methods to get at the same data, e.g.
```ruby
work["queue"] # Old
work.queue # New
```
- Fix Ruby 3.3 warnings around `base64` gem [#6151, earlopain]
7.2.0
----------
- `sidekiq_retries_exhausted` can return `:discard` to avoid the deadset
and all death handlers [#6091]
- Metrics filtering by job class in Web UI [#5974]
- Better readability and formatting for numbers within the Web UI [#6080]
- Add explicit error if user code tries to nest test modes [#6078]
```ruby
Sidekiq::Testing.inline! # global setting
Sidekiq::Testing.fake! do # override within block
# ok
Sidekiq::Testing.inline! do # can't override the override
# not ok, nested
end
end
```
- **SECURITY** Forbid inline JavaScript execution in Web UI [#6074]
- Adjust redis-client adapter to avoid `method_missing` [#6083]
This can result in app code breaking if your app's Redis API usage was
depending on Sidekiq's adapter to correct invalid redis-client API usage.
One example:
```ruby
# bad, not redis-client native
# Unsupported command argument type: TrueClass (TypeError)
Sidekiq.redis { |c| c.set("key", "value", nx: true, ex: 15) }
# good
Sidekiq.redis { |c| c.set("key", "value", "nx", "ex", 15) }
```
7.1.6
----------
......@@ -150,6 +213,11 @@ end
- Job Execution metrics!!!
- See `docs/7.0-Upgrade.md` for release notes
6.5.{10,11,12}
----------
- Fixes for Rails 7.1 [#6067, #6070]
6.5.9
----------
......
# frozen_string_literal: true
source "https://rubygems.org"
gemspec
gem "rake"
RAILS_VERSION = "~> 7.0.4"
RAILS_VERSION = "~> 7.1"
gem "actionmailer", RAILS_VERSION
gem "actionpack", RAILS_VERSION
gem "activejob", RAILS_VERSION
......@@ -15,7 +13,7 @@ gem "redis-client"
# gem "bumbler"
# gem "debug"
gem "sqlite3", platforms: :ruby
gem "sqlite3", "~> 1.4", platforms: :ruby
gem "activerecord-jdbcsqlite3-adapter", platforms: :jruby
gem "after_commit_everywhere", require: false
gem "yard"
......
PATH
remote: .
specs:
sidekiq (7.1.6)
sidekiq (7.2.4)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.14.0)
redis-client (>= 0.19.0)
GEM
remote: https://rubygems.org/
specs:
actionmailer (7.0.8)
actionpack (= 7.0.8)
actionview (= 7.0.8)
activejob (= 7.0.8)
activesupport (= 7.0.8)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.8)
actionview (= 7.0.8)
activesupport (= 7.0.8)
rack (~> 2.0, >= 2.2.4)
actionmailer (7.2.0)
actionpack (= 7.2.0)
actionview (= 7.2.0)
activejob (= 7.2.0)
activesupport (= 7.2.0)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.2.0)
actionview (= 7.2.0)
activesupport (= 7.2.0)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (7.0.8)
activesupport (= 7.0.8)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actionview (7.2.0)
activesupport (= 7.2.0)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.8)
activesupport (= 7.0.8)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.2.0)
activesupport (= 7.2.0)
globalid (>= 0.3.6)
activemodel (7.0.8)
activesupport (= 7.0.8)
activerecord (7.0.8)
activemodel (= 7.0.8)
activesupport (= 7.0.8)
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
activemodel (7.2.0)
activesupport (= 7.2.0)
activerecord (7.2.0)
activemodel (= 7.2.0)
activesupport (= 7.2.0)
timeout (>= 0.4.0)
activesupport (7.2.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
tzinfo (~> 2.0)
after_commit_everywhere (1.3.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
after_commit_everywhere (1.4.0)
activerecord (>= 4.2)
activesupport
ast (2.4.2)
builder (3.2.4)
concurrent-ruby (1.2.3)
base64 (0.2.0)
bigdecimal (3.1.8)
builder (3.3.0)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.4)
docile (1.4.0)
erubi (1.12.0)
docile (1.4.1)
drb (2.2.1)
erubi (1.13.0)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
json (2.7.1)
io-console (0.7.2)
irb (1.14.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
logger (1.6.0)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
......@@ -72,34 +88,46 @@ GEM
net-imap
net-pop
net-smtp
maxitest (5.4.0)
minitest (>= 5.14.0, < 5.21.0)
method_source (1.0.0)
maxitest (5.6.0)
minitest (>= 5.14.0, < 5.25.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.20.0)
net-imap (0.4.9.1)
minitest (5.24.1)
net-imap (0.4.14)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0.1)
net-smtp (0.5.0)
net-protocol
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86-linux)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.0-arm64-darwin)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.5)
parallel (1.26.3)
parser (3.3.4.2)
ast (~> 2.4.1)
racc
racc (1.7.3)
rack (2.2.8)
psych (5.1.2)
stringio
racc (1.8.1)
rack (3.1.7)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
......@@ -107,89 +135,107 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.0.8)
actionpack (= 7.0.8)
activesupport (= 7.0.8)
method_source
railties (7.2.0)
actionpack (= 7.2.0)
activesupport (= 7.2.0)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.1.0)
redis-client (0.19.1)
rake (13.2.1)
rdoc (6.7.0)
psych (>= 4.0.0)
redis-client (0.22.2)
connection_pool
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.59.0)
regexp_parser (2.9.2)
reline (0.5.9)
io-console (~> 0.5)
rexml (3.3.6)
strscan
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-performance (1.20.2)
rubocop-ast (1.32.1)
parser (>= 3.3.1.0)
rubocop-performance (1.21.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-prof (1.7.0)
ruby-progressbar (1.13.0)
securerandom (0.3.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sqlite3 (1.7.1)
mini_portile2 (~> 2.8.0)
sqlite3 (1.7.1-arm64-darwin)
standard (1.33.0)
sqlite3 (1.7.3-aarch64-linux)
sqlite3 (1.7.3-arm-linux)
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x86-linux)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
standard (1.40.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.59.0)
rubocop (~> 1.65.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.3)
standard-performance (~> 1.4)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.3.1)
standard-performance (1.4.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.20.2)
thor (1.3.0)
rubocop-performance (~> 1.21.0)
stringio (3.1.1)
strscan (3.1.0)
thor (1.3.1)
timeout (0.4.1)
toxiproxy (2.0.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
yard (0.9.34)
zeitwerk (2.6.12)
useragent (0.16.10)
webrick (1.8.1)
yard (0.9.36)
zeitwerk (2.6.17)
PLATFORMS
arm64-darwin-23
ruby
aarch64-linux
arm-linux
arm64-darwin
x86-linux
x86_64-darwin
x86_64-linux
DEPENDENCIES
actionmailer (~> 7.0.4)
actionpack (~> 7.0.4)
activejob (~> 7.0.4)
activerecord (~> 7.0.4)
actionmailer (~> 7.1)
actionpack (~> 7.1)
activejob (~> 7.1)
activerecord (~> 7.1)
activerecord-jdbcsqlite3-adapter
after_commit_everywhere
maxitest
railties (~> 7.0.4)
railties (~> 7.1)
rake
redis-client
ruby-prof
sidekiq!
simplecov
sqlite3
sqlite3 (~> 1.4)
standard
toxiproxy
yard
BUNDLED WITH
2.5.5
2.5.17
......@@ -3,11 +3,11 @@ Copyright (c) Contributed Systems LLC
This product includes software developed at
Contributed Systems LLC(https://contribsys.com/).
Modifications to the following files were made on 30 Jan 2024 by GitLab:
- sidekiq.gemspec
Modifications to the following files were made on 2024-08-22 by GitLab:
- lib/sidekiq/redis_client_adapter.rb
- lib/sidekiq/redis_connection.rb
- lib/sidekiq/api.rb
- lib/sidekiq/cli.rb
- lib/sidekiq/paginator.rb
- lib/sidekiq/scheduled.rb
- sidekiq.gemspec
- test/web_test.rb
......@@ -14,11 +14,11 @@ Rails to make background processing dead simple.
Requirements
-----------------
- Redis: 6.2+
- Redis: Redis 6.2+ or Dragonfly 1.13+
- Ruby: MRI 2.7+ or JRuby 9.3+.
Sidekiq 7.0 supports Rails 6.0+ but does not require it.
As of 7.2, Sidekiq supports Dragonfly as an alternative to Redis for data storage.
Installation
-----------------
......
#!/usr/bin/env ruby
#
# bin/bench is a helpful script to load test and
# performance tune Sidekiq's core. It's a configurable script,
# which accepts the following parameters as ENV variables.
#
# QUEUES
# Number of queues to consume from. Default is 8
#
# PROCESSES
# The number of processes this benchmark will create. Each process, consumes
# from one of the available queues. When processes are more than the number of
# queues, they are distributed to processes in round robin. Default is 8
#
# ELEMENTS
# Number of jobs to push to each queue. Default is 1000
#
# ITERATIONS
# Each queue pushes ITERATIONS times ELEMENTS jobs. Default is 1000
#
# PORT
# The port of the Dragonfly instance. Default is 6379
#
# IP
# The ip of the Dragonfly instance. Default is 127.0.0.1
#
# Example Usage:
#
# > RUBY_YJIT_ENABLE=1 THREADS=10 PROCESSES=8 QUEUES=8 bin/multi_queue_bench
#
# None of this script is considered a public API and may change over time.
#
# Quiet some warnings we see when running in warning mode:
# RUBYOPT=-w bundle exec sidekiq
$TESTING = false
puts RUBY_DESCRIPTION
require "bundler/setup"
Bundler.require(:default, :load_test)
class LoadWorker
include Sidekiq::Job
sidekiq_options retry: 1
sidekiq_retry_in do |x|
1
end
def perform(idx, ts = nil)
puts(Time.now.to_f - ts) if !ts.nil?
# raise idx.to_s if idx % 100 == 1
end
end
def Process.rss
`ps -o rss= -p #{Process.pid}`.chomp.to_i
end
$iterations = ENV["ITERATIONS"] ? Integer(ENV["ITERATIONS"]) : 1_000
$elements = ENV["ELEMENTS"] ? Integer(ENV["ELEMENTS"]) : 1_000
$port = ENV["PORT"] ? Integer(ENV["PORT"]) : 6379
$ip = ENV["IP"] ? String(ENV["IP"]) : "127.0.0.1"
class Loader
def initialize
@iter = $iterations
@count = $elements
end
def configure(queue)
@x = Sidekiq.configure_embed do |config|
config.redis = {db: 0, host: $ip, port: $port}
config.concurrency = Integer(ENV.fetch("THREADS", "30"))
config.queues = queue
config.logger.level = Logger::WARN
config.average_scheduled_poll_interval = 2
config.reliable! if defined?(Sidekiq::Pro)
end
@self_read, @self_write = IO.pipe
%w[INT TERM TSTP TTIN].each do |sig|
trap sig do
@self_write.puts(sig)
end
rescue ArgumentError
puts "Signal #{sig} not supported"
end
end
def handle_signal(sig)
launcher = @x
Sidekiq.logger.debug "Got #{sig} signal"
case sig
when "INT"
# Handle Ctrl-C in JRuby like MRI
# http://jira.codehaus.org/browse/JRUBY-4637
raise Interrupt
when "TERM"
# Heroku sends TERM and then waits 30 seconds for process to exit.
raise Interrupt
when "TSTP"
Sidekiq.logger.info "Received TSTP, no longer accepting new work"
launcher.quiet
when "TTIN"
Thread.list.each do |thread|
Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread["label"]}"
if thread.backtrace
Sidekiq.logger.warn thread.backtrace.join("\n")
else
Sidekiq.logger.warn "<no backtrace available>"
end
end
end
end
def setup(queue)
Sidekiq.logger.error("Setup RSS: #{Process.rss}")
Sidekiq.logger.error("Pushing work to queue: #{queue}")
start = Time.now
@iter.times do
arr = Array.new(@count) { |idx| [idx] }
# Sidekiq always prepends "queue:" to the queue name,
# that's why we pass 'q1', 'q2', etc instead of 'queue:q1'
Sidekiq::Client.push_bulk("class" => LoadWorker, "args" => arr, "queue" => queue)
$stdout.write "."
end
puts "Done"
end
def monitor_single(queue)
q = "queue:#{queue}"
@monitor_single = Thread.new do
GC.start
loop do
sleep 0.2
total = Sidekiq.redis do |conn|
conn.llen q
end
if total == 0
sleep 0.1
@x.stop
Process.kill("INT", $$)
break
end
end
end
end
def monitor_all(queues)
@monitor_all = Thread.new do
GC.start
loop do
sleep 0.2
qsize = 0
queues.each do |q|
tmp = Sidekiq.redis do |conn|
conn.llen q
end
qsize = qsize + tmp
end
total = qsize
if total == 0
ending = Time.now - @start
size = @iter * @count * queues.length()
Sidekiq.logger.error("Done, #{size} jobs in #{ending} sec, #{(size / ending).to_i} jobs/sec")
Sidekiq.logger.error("Ending RSS: #{Process.rss}")
sleep 0.1
@x.stop
Process.kill("INT", $$)
break
end
end
end
end
def run(queues, queue, monitor_all_queues)
Sidekiq.logger.warn("Consuming from #{queue}")
if monitor_all_queues
monitor_all(queues)
else
monitor_single(queue)
end
@start = Time.now
@x.run
while (readable_io = IO.select([@self_read]))
signal = readable_io.first[0].gets.strip
handle_signal(signal)
end
# normal
rescue Interrupt
rescue => e
raise e if $DEBUG
warn e.message
warn e.backtrace.join("\n")
exit 1
ensure
@x.stop
end
end
def setup(queue)
ll = Loader.new
ll.configure(queue)
ll.setup(queue)
end
def consume(queues, queue, monitor_all_queues)
ll = Loader.new
ll.configure(queue)
ll.run(queues, queue, monitor_all_queues)
end
# We assign one queue to each sidekiq process
def run(number_of_processes, total_queues)
read_stream, write_stream = IO.pipe
queues = []
(0..total_queues-1).each do |idx|
queues.push("queue:q#{idx}")
end
Sidekiq.logger.info("Queues are: #{queues}")
# Produce
start = Time.now
(0..total_queues-1).each do |idx|
Process.fork do
queue_num = "q#{idx}"
setup(queue_num)
end
end
queue_sz = $iterations * $elements * total_queues
Process.waitall
ending = Time.now - start
#Sidekiq.logger.info("Pushed #{queue_sz} in #{ending} secs")
# Consume
(0..number_of_processes-1).each do |idx|
Process.fork do
# First process only consumes from it's own queue but monitors all queues.
# It works as a synchronization point. Once all processes finish
# (that is, when all queues are emptied) it prints the the stats.
if idx == 0
queue = "q#{idx}"
consume(queues, queue, true)
else
queue = "q#{idx % total_queues}"
consume(queues, queue, false)
end
end
end
Process.waitall
write_stream.close
results = read_stream.read
read_stream.close
end
$total_processes = ENV["PROCESSES"] ? Integer(ENV["PROCESSES"]) : 8;
$total_queues = ENV["QUEUES"] ? Integer(ENV["QUEUES"]) : 8;
run($total_processes, $total_queues)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment