-
Notifications
You must be signed in to change notification settings - Fork 151
Conversation
Thanks man, my test writing's a little rusty. I actually saw a couple I'll think about it some more later today. |
I think the full-proof solution involves creating
What do you think @dblock? |
@latency = nil | ||
true | ||
Connection::Manager.shutdown(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should still return true
here , and not nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring says # @return [ nil ] Nothing.
, so we should update that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point... if doc says that, I think it is fine to return nil
One small comment, otherwise I will merge after |
thanks |
@fedenusy Clearly you need a lock to decide whether to call |
Also anything that calls Hopefully this fix is good enough. |
@arthurnn is this released and also added to mongoid ? |
@sahin not yet released. |
@arthurnn, it can be so good to have mongoid 4.0.3 with just a bump to the new moped |
Fyi, been running this well in production at artsy.net for the last 72 hours. |
+1 |
@arthurnn , thx a lot. can u also update mongoid ? |
We should not need to update mongoid, as it uses Moped 2.0.x : https://github.com/mongoid/mongoid/blob/master/mongoid.gemspec#L24 a |
@arthurnn of course, we will do "bundle update moped" but then only the people who is aware of the issue will have fix. |
It isn't fixed. It happens in multiple threads. mongoid.yml: development:
sessions:
default:
database: test_development
hosts:
- localhost:27017
options:
options:
preload_models: true moped_multi_thread_fail_test.rb: require 'mongoid'
NUMBER_THREADS = 500
ENV["MONGOID_ENV"] = 'development'
Mongoid.load!('mongoid.yml')
class Test
include Mongoid::Document
field :cnt, type: Integer, default: 0
end
def multi_thread_update_counters(id, thread_count)
threads = []
thread_count.times do |i|
threads[i] = Thread.new do
Test.collection.find({_id: id}).update({'$inc' => {'cnt' => 1}}, {safe: true, upsert: true})
end
end
threads.each {|t| t.join }
end
multi_thread_update_counters(Test.create.id, NUMBER_THREADS) use:
And 'ConnectionPool::PoolShuttingDownError':
|
Fix from @fedenusy for #345 + a spec.