Hi all,
I hope you can help. I am getting a cursor timeout exception thrown
when I am attempting a mapreduce from a php script.
PHP Fatal error: Uncaught exception 'MongoCursorTimeoutException'
with message 'cursor timed out' in /home/matt/sandbox/moria/
src.tl/
test_install.php:59
Stack trace:
#0 /home/matt/sandbox/moria/
src.tl/test_install.php(59): MongoDB-
>command(Array)
#1 {main}
thrown in /home/matt/sandbox/moria/
src.tl/test_install.php on line
59
The code is (a bit sloppy as I am flailing a bit here):
$map = new MongoCode("
function() {
emit( { event_id: this.event_id,
event_ts: this.event_ts,
event_name: this.event_name,
fb_id: this.fb_id
},
{count: 1}
);
}");
$reduce = new MongoCode("
function(k, v) {
var total = 0;
for (var i = 0; i < v.length; i++) {
total += v[i].count;
}
return {count: total};
} ");
$query = array('event_name' => 'STATE_FirstTimePlayOfGame',
'event_ts' => array('$gte' => '2010-07-01', '$lt' =>
'2010-07-02'));
$command = array("mapreduce" => "events",
"map" => $map,
"reduce" => $reduce,
"query" => $query);
$db_host = "localhost";
$db_name = "moria";
$collection_name = "events";
try {
$mdb_conn = new Mongo($db_host);
}
catch (MongoConnectionException $e) {
$msg = "Error connecting to MongoDB\n";
die($msg);
}
echo "Connected\n";
$moria = $mdb_conn->$db_name;
echo "got moria\n";
// set events collection
$events = $moria->selectCollection($collection_name);
echo "got events\n";
echo "setting timeout\n";
$cursor = $events->find()->timeout(300000);
echo "running command\n";
$installs = $moria->command($command);
-----
I don't get any farther than this. The collection is pretty big (42
million) and though I plan to shard, its not currently sharded.
Any ideas?
Thanks in advance for any help / insights you can provide,
Matt