コード:にMongoCursorException - 見つからないカーソル(MongoDBのPHPドライバ)
try {
$documentsFind = $client->$db->$collection->find([
// query
]);
if ($documentsFind) {
foreach ($documentsFind as $product) {
// code...
}
}
catch (MongoCursorException $e) {
echo "error message: ".$e->getMessage()."\n";
echo "error code: ".$e->getCode()."\n";
}
エラー:
Fatal error: Uncaught MongoDB\Driver\Exception\RuntimeException: Cursor not found, cursor id: 31837896248 in ...
外にカーソルが存在しないようだが、回?それをどうやって防ぐことができますか?
編集がを追加する:私はやってみました:
if ($documentsFind) {
$documentsFind->immortal(true); // keep alive
foreach ($documentsFind as $product) {
// code...
}
}
しかし、それはCall to undefined method MongoDB\Driver\Cursor::immortal()
になります。
を見ることができ、エラーは最初の実行時に表示されるかされませんいくつかのエントリを読み込むことができますか? – cb0
DBからかなりの数のドキュメントを取り出しますが、ある時点でタイムアウトします。 'mongod --setParameter cursorTimeoutMillis = 9000000'でこれを一時的に回避することができました。 – 3zzy