trying test automatic failover using mongoid 4.0.2 gem , using mongodb 2.4.3
to simulate i'm using test code:
require 'mongoid' class testclass include mongoid::document store_in collection: "test", database: "test" field :uuid, type: string end mongoid.load!("config/mongoid.yml", :test) batch = (1..100).map { |x| testclass.new({ uuid: x }) } batch.each_with_index { |x, i| begin x.save sleep(5.seconds) puts "saved #{i} records" if i%10 == 0 rescue exception => e puts e.message end }
in between saves, jumped on mongodb , did rs.stepdown() on primary node of mongo cluster, unfortunately results in following errors in test app:
see https://github.com/mongodb/mongo/blob/master/docs/errors.md details error. moped::errors::operationfailure operation: #<moped::protocol::command @length=68 @request_id=192 @response_to=0 @op_code=2004 @flags=[] @full_collection_name="test.$cmd" @skip=0 @limit=-1 @selector={:getlasterror=>1, :w=>1} @fields=nil> failed error 10058: "not master"
my mongoid configuration looks thus:
test: sessions: default: database: test_db hosts: - 192.168.1.10:27017 - 192.168.1.11:27017 options: max_retries: 10 retry_interval: 1
any idea i'm doing wrong here? thought mongoid driver automatically detect changes in cluster , automatically retry request after updates cluster state on client / ruby side?
Comments
Post a Comment