标签归档:MongoDB

MongoDB之no db response数据库没有响应

Published / by 高成 / MongoDB之no db response数据库没有响应有1条评论

今天查看PHP的error log有很多错误产生,有Fatal error也有Warning,本着错误的级别先开始处理Fatal error除了几条还被搜索机器人抓取的不在使用的页面产生这种错误外,发现了一个多行的Fatal error仔细查看下是:

[17-Jan-2012 11:16:19] PHP Fatal error:  Uncaught exception 'MongoCursorException' with message 'no db response' in XXXXX.php:194

乍一看是为捕获抛出的异常,异常的错误信息是'no db response'数据库没有响应,接下去查看代码:

省略...
$query = array('type' => 5);
$cursor = $collection->find($query);
foreach($cursor as $key => $val) {//出错的行
	省略...
}
省略...

变量$cursor为查询MongoDB的返回结果,但是抛出的异常是'MongoCursorException'异常信息是'no db response',查看PHP手册解释是:This may not even be an error, for example, the database command "shutdown" returns no response. However, if you were expecting a response, this means the database didn't give one.坑爹的PHP手册上来就说:This may not even be an error(这甚至有可能不会是一个错误),for example, the database command "shutdown" returns no response.(例如,数据库输入'shutdown'命令而没有获得相应)。
访遍Google、百度没有获得满意的答案,不过问题应该已经比较清晰出现在了MongoDB或是网络上面,于是继续想办法查找问题中,截止到博文发布还没有找到问题原因!