mongoid / origin

A Ruby DSL for building MongoDB queries
http://mongoid.org/en/origin/index.html
MIT License
62 stars 29 forks source link

ReplicaSet Config schema since 2.4.6 #30

Closed MobilUser closed 12 years ago

MobilUser commented 12 years ago

I am a bit puzzled on what has changed from previous version to this one. I updated my bundle this morning from mongoid 2.4.5 and mongo 1.6.0 to mongoid 2.4.6 and mongo 1.6.1. SInce that time I see the following errors/warnings in on my production server:

Initiating a ReplSetConnection with seeds passed as individual [host, port] array arguments is deprecated. Please specify hosts as an array of 'host:port' strings; the old format will be removed in v2.0 max_retries_on_connection_failure is not a valid option for Mongo::ReplSetConnection hosts is not a valid option for Mongo::ReplSetConnection database is not a valid option for Mongo::ReplSetConnection

My mongoid.yml looks as: production: database: xxxx hosts:

That produces the warnings .. Changed also to: max_retries_on_connection_failure: 5 logger: false database: xxx hosts: [[s1, 27017], [s2, 27017], [s3, 27017]] read: :secondary

Didn't change anything.

So what is the current configuration schema. The mongoid.org docs request the above schema. By the way, I am on ree-1.8.7-2012.01 and RoR 3.2.2 and MongoDB 2.0.2

Any hint is appreciated.

Txs

durran commented 12 years ago

Wrong repo for this issue.

This commit fixes the warnings: https://github.com/mongoid/mongoid/commit/e2f50c436158e2b0d69bed34dff12d2747cdda74

Then change your yaml for the host/port warnings:

production:
  database: xxxx
  hosts:
    - - s1:27017
    - - s2:27017
    - - s3:27017
  read: :secondary
MobilUser commented 12 years ago

Txs for the swift reply and sorry for the wrong repo..

Silly question, as this is now the 1st time for me ...

I always get the gems from rubygems.org via gem install .. what to do now to get the suggested commit?

Txs

durran commented 12 years ago

You can point at the 2.4.0-stable branch from your Gemfile until 2.4.7 is released:

gem "mongoid", git: "git://github.com/mongoid/mongoid.git", branch: "2.4.0-stable"
MobilUser commented 12 years ago

Excellent! Txs

nkriege commented 12 years ago

This commit and your suggested change to the yaml format do silence the warnings, but yaml in this format does not actually work properly. With the original format, a warning is logged but the seeds are properly initialized:

$ rails console Initiating a ReplSetConnection with seeds passed as individual [host, port] array arguments is deprecated. Please specify hosts as an array of 'host:port' strings; the old format will be removed in v2.0 irb(main):001:0> Mongoid.master.connection.seeds => [["s1", 27017], ["s2", 27017], ["s3", 27017]]

With the new format, there is no warning, but only the first server is added to seeds:

$ rails console irb(main):001:0> Mongoid.master.connection.seeds => [["s1", 27017]]

It looks like Mongo::ReplSetConnection#initialize now expects an array of host:port strings followed by a hash of options rather than a single list including host:port pairs and the options hash.

etiennebarrie commented 12 years ago

As @nkriege points out, the suggested change won’t actually use all seeds as expected. Instead of an array of 1-element arrays, you need a 1-element array containing the actual array of 'host:port' strings. It’s just a matter of removing the dashes:

production:
  database: xxxx
  hosts:
    - - s1:27017
      - s2:27017
      - s3:27017
  read: :secondary
MobilUser commented 12 years ago

txs for the reply, changed my yml file accordingly.

barmstrong commented 12 years ago

Just got bit by this. The array of arrays seems a bit confusing here.

Looks like this got cleaned up in mongoid 3 though: http://mongoid.org/en/mongoid/docs/installation.html#replica

Nice!