我有perl脚本来运行mongo查询。
#!/usr/bin/perl
use strict;
use warnings;
use MongoDB;
use Data::Printer;
use MongoDB::QueryResult;
my $mc = MongoDB->connect('mongodb://user:pass@localhost:27012/test_db');
my $coll = $mc->ns("test_db.collection1");
my @permissibleCars =
("ABC","DEF","XYZ","MNO","PQR");
my @pipeline = (
{
'$match' => {
"Contract" => { '$in' => \@permissibleCars },
"Class" => "Right"
}
},
{ '$group' => { _id => '$Contract', count => { '$sum' => 9 } } }
);
my $res = $coll->aggregate( \@pipeline, { allowDiskUse => 1 } );
# query & iterate
while (my $row = $res->next) {
# it is 'p', from Data::Printer!
p $row;
}
随机失败并出现以下错误: -
MongoDB::NetworkTimeout: Timed out while waiting for socket to become ready for reading
现在,根据我的阅读,我们需要将socketTimeoutMS值更改为更大的值。但我不知道我在哪里设置它?
此外,maxTimeMS或maxPoolSize在这种情况下会有所帮助吗? @permissibleCars字段可能有大约10K记录。
问候。