Skip to content

Instantly share code, notes, and snippets.

@hobodave
Last active May 18, 2017 22:12
Show Gist options
  • Save hobodave/972c209a22d54b0d1769b0701547404c to your computer and use it in GitHub Desktop.
Save hobodave/972c209a22d54b0d1769b0701547404c to your computer and use it in GitHub Desktop.
CONCURRENCY = 100 # Ensure adequate pool size in database.yml
barrier = Concurrent::CyclicBarrier.new(CONCURRENCY)
jobs = Array.new(CONCURRENCY) do
lambda do
ClientNodeDetail.last
end
end
process = lambda do |i|
barrier.wait
begin
Rails.application.executor.wrap { jobs[i].call }
ensure
barrier.wait
end
end
threads = CONCURRENCY.times.map { |i| Thread.new(i, &process) }
threads.map(&:join)
=begin
NoMethodError: undefined method `default_scope_override' for #<Class:0x152d2a58>
Did you mean? default_scope_override=
from org/jruby/RubyBasicObject.java:1653:in `method_missing'
from /Users/davida/.rvm/gems/jruby-9.1.9.0@backbeat/gems/activerecord-5.0.3/lib/active_record/dynamic_matchers.rb:21:in `method_missing'
from /Users/davida/.rvm/gems/jruby-9.1.9.0@backbeat/gems/activerecord-5.0.3/lib/active_record/scoping/default.rb:111:in `build_default_scope'
from /Users/davida/.rvm/gems/jruby-9.1.9.0@backbeat/gems/activerecord-5.0.3/lib/active_record/scoping/named.rb:33:in `default_scoped'
from /Users/davida/.rvm/gems/jruby-9.1.9.0@backbeat/gems/activerecord-5.0.3/lib/active_record/scoping/named.rb:28:in `all'
from /Users/davida/.rvm/gems/jruby-9.1.9.0@backbeat/gems/activerecord-5.0.3/lib/active_record/querying.rb:3:in `last'
from (irb):7:in `block in evaluate'
from (irb):17:in `block in evaluate'
from /Users/davida/.rvm/gems/jruby-9.1.9.0@backbeat/gems/activesupport-5.0.3/lib/active_support/execution_wrapper.rb:85:in `wrap'
from (irb):17:in `block in evaluate'
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment