Re: [mongodb-user] PHP driver : one replica set, but two different db/user/passwords.

93 views
Skip to first unread message

Hannes Magnusson

unread,
Dec 6, 2012, 11:08:03 PM12/6/12
to mongod...@googlegroups.com, heman...@gmail.com
On Wed, Dec 5, 2012 at 5:18 PM, Hemant Bist <heman...@gmail.com> wrote:
> Hi,
> We are running into a case which looks like a bug in PHP driver. Would
> really appreciate any pointers in debugging/workarounds. Sample script that
> replicates our problem below.
> We have the case where one replica set has two dbs that can be accessed by
> two separate user/passwords.




This is indeed a bug in the driver.
I've create a ticket for it[1], and a pull requests[2], which is
waiting for a review.

I can't think of any workarounds though... But please do try out the
patch if you can!

-Hannes


[1] https://jira.mongodb.org/browse/PHP-631
[2] https://github.com/mongodb/mongo-php-driver/pull/244

Manasi Sahasrabudhe

unread,
Jan 4, 2013, 8:15:14 PM1/4/13
to mongod...@googlegroups.com, heman...@gmail.com
mongodb-php-driver that we are using is old. Currently we are on 1.2.10. I tried upgrading to 1.3.2 and did not see this error during my initial testing.
However I have 2 related questions,
1. Currently we are calling SlaveOkay methods because we would like to send reads to secondaries. However once we upgrade our php-client to newer version we wont be able to use those as they are deprecated.
2. We are running MongoDB 2.0.6 on db server which does not support ReadPreferences (as it was introduced in 2.2). So whats the compatible version of mongo-php-driver with mongodb 2.0.6? and with which we still be able to use slaveokay or similar?
 Any thoughts?
Thanks,
-Manasi

Justin Case

unread,
Jan 4, 2013, 10:42:04 PM1/4/13
to mongod...@googlegroups.com
On Jan 5, 2013, at 2:15 AM, Manasi Sahasrabudhe wrote:

mongodb-php-driver that we are using is old. Currently we are on 1.2.10. I tried upgrading to 1.3.2 and did not see this error during my initial testing.
However I have 2 related questions,
1. Currently we are calling SlaveOkay methods because we would like to send reads to secondaries. However once we upgrade our php-client to newer version we wont be able to use those as they are deprecated.
2. We are running MongoDB 2.0.6 on db server which does not support ReadPreferences (as it was introduced in 2.2). So whats the compatible version of mongo-php-driver with mongodb 2.0.6? and with which we still be able to use slaveokay or similar?
 Any thoughts?
Thanks,
-Manasi

1.2.12

slaveOkay was deprecated in 1.2.11 but restored for 1.2.12 because Read Preferences wasn't implemented yet:

Derick Rethans

unread,
Jan 7, 2013, 6:35:14 AM1/7/13
to mongod...@googlegroups.com, heman...@gmail.com
On Fri, 4 Jan 2013, Manasi Sahasrabudhe wrote:

> mongodb-php-driver that we are using is old. Currently we are on 1.2.10. I
> tried upgrading to 1.3.2 and did not see this error during my initial
> testing.
> However I have 2 related questions,
> 1. Currently we are calling SlaveOkay methods because we would like to send
> reads to secondaries. However once we upgrade our php-client to newer
> version we wont be able to use those as they are deprecated.

How are you calling slaveOkay, directly on the cursor (and on every
cursor)? If it's through every one, you can set a read preference in
general, either in the constructor or on the connection, database or
collection level: http://php.net/manual/en/mongodb.setreadpreference.php
and http://php.net/manual/en/mongo.readpreferences.php

We'll be adding a per-cursor setReadPreference soon:
https://jira.mongodb.org/browse/PHP-483

> 2. We are running MongoDB 2.0.6 on db server which does not support
> ReadPreferences (as it was introduced in 2.2). So whats the compatible
> version of mongo-php-driver with mongodb 2.0.6? and with which we still be
> able to use slaveokay or similar?

This is all implemented in the driver, and not in the database. So the
1.3 series should work just fine with 2.0.6 - although there are/were
some issues in case you are using sharding that we are figuring out and
fixing.

cheers,
Derick

--
{
website: [ "http://mongodb.org", "http://derickrethans.nl" ],
twitter: [ "@derickr", "@mongodb" ]
}

Manasi Sahasrabudhe

unread,
Jan 7, 2013, 1:18:24 PM1/7/13
to mongod...@googlegroups.com, heman...@gmail.com
So, mongo-php-driver-1.3.2 and mongo server 2.0.6 should work fine, and we should be able to get benefit of setting read preferences as well, right?
Isnt it true that support for readPreferences was added in Mongo 2.2+?

To answer your first question, we are setting slaveOkay at connection level for now but would love to get the cursor level config too.
Thanks,
-Manasi

Derick Rethans

unread,
Jan 7, 2013, 2:27:04 PM1/7/13
to mongod...@googlegroups.com, heman...@gmail.com
On Mon, 7 Jan 2013, Manasi Sahasrabudhe wrote:

> So, mongo-php-driver-1.3.2 and mongo server 2.0.6 should work fine, and we
> should be able to get benefit of setting read preferences as well, right?
> Isnt it true that support for readPreferences was added in Mongo 2.2+?

Only for sharding, where read preference have to be implemented in the
mongoS that comes with 2.2. For replicasets and standalone it should
work.

> To answer your first question, we are setting slaveOkay at connection level
> for now but would love to get the cursor level config too.

Yup - that's the issue I'm currently working on (PHP-639 and PHP-483)

Jeremy Mikola

unread,
Jan 18, 2013, 12:41:01 PM1/18/13
to mongod...@googlegroups.com, heman...@gmail.com
Just following up. With the 1.3.3 release, we now have get/setReadPreference() methods on MongoCursor. See: changelog.
Reply all
Reply to author
Forward
0 new messages