2014年7月29日星期二

MongoDB cursor timeout

PHP 的 MongoDB 扩展里,设置查询超时:
MongoCursor::$timeout = -1;


之前,一直以为 find 之后的 cursor 设置 timeout 为 -1 后,应该就表示查询永不超时,但在循环结果集或是 count 时还是报 cursor timed out (timeout: 30000, time left: 0:0, status: 0)。参照 记一次MongoDB性能问题 找问题原因,也没解决。直到看了 PHP Mongo's driver has no effects on Mongo Cursor timeout 这里才知道,设置超时需要按上面来设置。

附火丁笔记里提到的查找方法:
使用 strace 跟踪了一下PHP脚本,发现进程卡在了recvfrom操作上:
shell> strace -f -r -p 
recvfrom(,
通过如下命令查询recvfrom操作的含义:
shell> apropos recvfrom
receive a message from a socket
或者按照下面的方式确认一下:
shell> lsof -p 
shell> ls -l /proc//fd/

没有评论:

发表评论