Using setSlaveOkay we can tell mongo driver that it is allowed to connect to slave servers and execute queries on them. Functionality is explained here php driver allows this to be set on every level connection, db, collection...

I suggest setting it on connection level and make it configurable with connection settings like bellow.

$conf['mongodb_connections'] = array(
     // Connection name/alias
      'default' => array(
       'host' => 'slave1',
       // Database name
       'db' => 'drupal_default',
       'slave_ok' => TRUE,

We would then set setSlaveOkay to true in mongodb function. I'm working on a patch.

#2 1793532_slave_ok.patch1.05 KBRok Žlender
Test request sent.
[ View ]


Rok Žlender’s picture

Oh php docs say setSlaveOkay is deprecated but they undeprecated it in release in latest php mongo driver

Rok Žlender’s picture

Status:Needs work» Needs review
new1.05 KB
Test request sent.
[ View ]

Attached patch allows crating a connection that allows querying slave.

marcingy’s picture

Status:Needs review» Reviewed & tested by the community
chx’s picture

Yes this is good to go.

Rok Žlender’s picture

Status:Reviewed & tested by the community» Fixed

Thanks chx and Marc for review. Committed to 7.x-1.x

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.