Read timed out after reading 0 bytes, waited for 30.000000 seconds

167 views
Skip to first unread message

Muhammad Shahzad

unread,
May 23, 2017, 2:28:25 AM5/23/17
to f3-fra...@googlegroups.com
Hello there,

It is very frustrating please suggest a best solution.

I have a collection with more than 1.5 million records and Mongo Mapper db class crashed when a search operation performed.

https://example.com/project/member/index?siteId=02

500 Internal Server Error

localhost:27017: Read timed out after reading 0 bytes, waited for 30.000000 seconds [/var/www/vhosts/project/lib/db/mongo/mapper.php:238]



But working here and also pagination is working too.
https://example.com/project/member/index




public function index($f3){

       list
($filter, $filter_array) = $this->_buildFilter($f3);    
       $mapper
= new \DB\Mongo\Mapper($f3->get('MongoDB'),'members');

       $page
=1;
        $limit
= 50;
       
if(isset($args['page'])){
            $page
= $args['page'] ;
            $limit
= 200;
       
}

       
if(empty($args["page"])) {
            $args
["page"] = 0;
       
}
        $filter_get
='';
       
if(is_array($filter)){
            $filter_get
= http_build_query($filter);
       
}

        $options
['order']= array('_id'=>-1);
        $content
= $mapper->paginate($args["page"], $limit, $filter_array, $options);

         
....

}
protected function _buildFilter($f3) {
        $args
= $f3->get("GET");
        $filter
= array();    
       
foreach($args as $key => $val) {
           
if(!empty($val) && !is_array($val)) {
                $filter
[$key] = $val;
           
}
       
}
        unset
($val);        
        $filters_array
= array();
       
foreach($filter as $i => $val) {

           
if($i == "siteId" && !empty($val)) {
                $filters_array
['$and'][]['siteId'] = $val;
           
}

       
}
           
return array($filter, $filters_array);    
   
}


mapper.php:238


function count($filter=NULL,$ttl=0) {
        $fw
=\Base::instance();
        $cache
=\Cache::instance();
       
if (!($cached=$cache->exists($hash=$fw->hash($fw->stringify(
           
[$filter])).'.mongo',$result)) || !$ttl ||
            $cached
[0]+$ttl<microtime(TRUE)) {
            $result
=$this->collection->count($filter?:[]);
           
if ($fw->get('CACHE') && $ttl)
               
// Save to cache backend
                $cache
->set($hash,$result,$ttl);
       
}
       
return $result;
   
}





Anatol

unread,
May 29, 2017, 12:51:16 AM5/29/17
to f3-fra...@googlegroups.com
Try to get more information about your query with log:

If this does not gives more idea you could raise the timeout limit.

cheers,

anatol


Reply all
Reply to author
Forward
0 new messages