当我调用 2 次或更多次从 mongo 中删除文档的函数时,我遇到了问题。
这是功能:
function deleteUser($userId){
$rangeQuery = array('metadata.userId' => intval($userId));
$cursor = $this->collection->remove($rangeQuery);
}
如果我只调用一次,函数就可以正常工作。问题是当我多次调用该函数时。例如:
deleteUser(2);
deleteUser(3);
deleteUser(4);
此代码仅删除第一个用户 (UserId = 2)。不会删除用户 3 或 4。我需要重新加载页面删除3,再重新加载删除4。在mongo中删除文档有什么限制吗?
这是使用 php mongolog 类的日志:
Message: CON INFO: mongo_get_read_write_connection: finding a STANDALONE connection
Message: CON FINE: found connection 81.4
Message: CON FINE: is_ping: pinging 81.4
Message: CON FINE: send_packet: read from header: 36
Message: CON FINE: send_packet: data_size: 17
Message: CON WARN: is_ping: last pinged at 1383224885; time: 11701ms
Message: REPLSET FINE: finding candidate servers
Message: REPLSET FINE: - all servers
Message: REPLSET FINE: filter_connections: adding connections:
Message: REPLSET FINE: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: REPLSET FINE: filter_connections: done
Message: REPLSET FINE: limiting by seeded/discovered servers
Message: REPLSET FINE: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: REPLSET FINE: limiting by seeded/discovered servers: done
Message: REPLSET FINE: sorting servers by priority and ping time
Message: REPLSET FINE: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: REPLSET FINE: sorting servers: done
Message: REPLSET FINE: selecting near servers
Message: REPLSET FINE: selecting near servers: nearest is 11701ms
Message: REPLSET FINE: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: REPLSET FINE: selecting near server: done
Message: REPLSET FINE: pick server: random element 0
Message: REPLSET INFO: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: IO FINE: is_gle_op: no
Message: CON FINE: The requested database (readings) is not what we have in the link info (admin)
Message: CON FINE: The link info has 'admin' as database, no need to clone it then
Message: CON INFO: mongo_get_read_write_connection: finding a STANDALONE connection
Message: CON FINE: found connection 81.4 (looking for 81.4)
Message: CON FINE: is_ping: pinging 81.4
Message: CON FINE: is_ping: skipping: last ran at 1383224885, now: 1383224885, time left: 5
Message: REPLSET FINE: finding candidate servers
Message: REPLSET FINE: - all servers
Message: REPLSET FINE: filter_connections: adding connections:
Message: REPLSET FINE: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: REPLSET FINE: filter_connections: done
Message: REPLSET FINE: limiting by seeded/discovered servers
Message: REPLSET FINE: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: REPLSET FINE: limiting by seeded/discovered servers: done
Message: REPLSET FINE: sorting servers by priority and ping time
Message: REPLSET FINE: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: REPLSET FINE: sorting servers: done
Message: REPLSET FINE: selecting near servers
Message: REPLSET FINE: selecting near servers: nearest is 11701ms
Message: REPLSET FINE: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: REPLSET FINE: selecting near server: done
Message: REPLSET FINE: pick server: random element 0
Message: REPLSET INFO: - connection: type: STANDALONE, socket: 1600, ping: 11701, hash: 81.4
Message: IO FINE: is_gle_op: no
谢谢你!