cpuguy83 / mongoid_connection_pool

Adds connection pooling for mongoid
MIT License
10 stars 4 forks source link

Does this work with Ruby MRI? #6

Open barmstrong opened 9 years ago

barmstrong commented 9 years ago

We are using Sidekiq, but with Ruby MRI 2.1.5. Tests don't seem to pass with ruby MRI though.

Does this only work with JRuby or Rubinius?

.....FF..F

Failures:

  1) Mongoid::Sessions::SessionPool.reap Reaps sessions from dead threads
     Failure/Error: expect(session_pool.reap).to be_true
       expected [#<Thread:0x007faa2c90ff78 dead>] to respond to `true?`
     # ./spec/session_pool_spec.rb:101:in `block (3 levels) in <top (required)>'

  2) Mongoid::Sessions::SessionPool.checkout Restarts the Reaper when it dies
     Failure/Error: session_pool.reaper.reaper.alive?.should be_false
       expected false to respond to `false?`
     # ./spec/session_pool_spec.rb:125:in `block (3 levels) in <top (required)>'

  3) Mongoid::Sessions.disconnect does not lock up when no sessions are created
     Failure/Error: expect(Mongoid::Sessions.disconnect).to_not raise_error
       expected no Exception but was not given a block
     # ./spec/sessions_spec.rb:21:in `block (3 levels) in <top (required)>'
barmstrong commented 9 years ago

Side note, I noticed it does use a relatively old version of thread_safe. Was going to try upgrading this to 0.3.4

cpuguy83 commented 9 years ago

There shouldn't be any reason to use this with MRI.

barmstrong commented 9 years ago

Sorry if sort of a noob question (might be something I'm not fully understanding). We are using sidekiq and it is doing tons of connections (one per job) since we are running it with concurrency. This is why this gem caught our eye and hoping it might help.

We are using ruby MRI and my understanding is that it supports multiple threads (maybe using "green threads" or fibers in ruby MRI? - not really sure how this works). http://stackoverflow.com/a/57802/76486

We are trying to minimize the number of connections that happen with sidekiq. Is mongoid_connection_pool a potential solution for that? Thx for the help.