-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
--TEST-- MongoDB\Driver\Server: Manager->getServer() returning correct server --SKIPIF-- <?php require "tests/utils/basic-skipif.inc"?> --FILE-- <?php require_once "tests/utils/basic.inc"; $manager = new MongoDB\Driver\Manager(REPLICASET); $doc = array("example" => "document"); $bulk = new \MongoDB\Driver\BulkWrite(); $bulk->insert($doc); $wresult = $manager->executeBulkWrite(NS, $bulk); $bulk = new \MongoDB\Driver\BulkWrite(); $bulk->insert($doc); /* writes go to the primary */ $server = $wresult->getServer(); /* This is the same server */ $server2 = $server->executeBulkWrite(NS, $bulk)->getServer(); /* Both are the primary, e.g. the same server */ var_dump($server == $server2); $rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY); /* Fetch a secondary */ $server3 = $manager->executeQuery(NS, new MongoDB\Driver\Query(array()), $rp)->getServer(); var_dump($server == $server3); var_dump($server->getPort(), $server3->getPort()); $bulk = new \MongoDB\Driver\BulkWrite(); $bulk->insert($doc); $result = $server3->executeBulkWrite(NS, $bulk); var_dump($result, $result->getServer()->getPort()); ?> ===DONE=== <?php exit(0); ?> --EXPECTF-- ===DONE===
The $server3->executeBulkWrite() should fail as it is directed to the secondary. It is however rerouted to the primary and scceeds.
- is related to
-
CDRIVER-586 Bulk Writes sent to wrong server in write command mode
- Closed
- related to
-
PHPC-187 getServer()->executeBulkWrite() uses wrong WriteConcern
- Closed