Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F633632
retryable-reads-002.phpt
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
retryable-reads-002.phpt
View Options
--TEST--
Retryable reads: executeQuery is retried once
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php skip_if_not_libmongoc_crypto(); ?>
<?php skip_if_test_commands_disabled(); ?>
<?php skip_if_not_clean(); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber
{
public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void
{
printf("Command started: %s\n", $event->getCommandName());
}
public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void
{
}
public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event): void
{
}
}
$manager = create_test_manager(URI, ['retryReads' => true]);
// Select a specific server for future operations to avoid mongos switching in sharded clusters
$server = $manager->selectServer(new \MongoDB\Driver\ReadPreference('primary'));
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$bulk->insert(['x' => 2]);
$server->executeBulkWrite(NS, $bulk);
configureTargetedFailPoint($server, 'failCommand', ['times' => 1], ['failCommands' => ['find'], 'closeConnection' => true]);
$observer = new Observer;
MongoDB\Driver\Monitoring\addSubscriber($observer);
$cursor = $server->executeQuery(NS, new \MongoDB\Driver\Query(['x' => 1]));
var_dump(iterator_count($cursor));
MongoDB\Driver\Monitoring\removeSubscriber($observer);
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
Command started: find
Command started: find
int(1)
===DONE===
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 15, 5:22 PM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
144249
Default Alt Text
retryable-reads-002.phpt (1 KB)
Attached To
Mode
R114 php-mongodb
Attached
Detach File
Event Timeline