ruby on rails - Can I set Mongoid query timeout? Mongoid don't kill long time query -
mongoid don't have timeout option.
 http://mongoid.org/en/mongoid/docs/installation.html
i want mongoid kill long time queries. how can set mongoid query timeout?
if nothing, mongoid wait long time below.
mongo > db.currentop()  {     "opid" : 34973,     "active" : true,     "secs_running" : 1317, // <- long!     "op" : "query",     "ns" : "db_name.collection_name",     "query" : {     "$msg" : "query not recording (too large)"   },     "client" : "123.456.789.123:46529",     "desc" : "conn42",     "threadid" : "0x7ff5fb95c700",     "connectionid" : 42,     "locks" : {     "^db_name" : "r"   },     "waitingforlock" : true,     "numyields" : 431282,     "lockstats" : {     "timelockedmicros" : {      "r" : numberlong(514304267),      "w" : numberlong(0)   },     "timeacquiringmicros" : {      "r" : numberlong(1315865170),      "w" : numberlong(0)     }   }  } 
actually, queries have timeout default. can set no_timeout option tell query never timeout.take here
you can configure timeout period using initializer, this
mongoid.configure |config|   config.master = mongo::connection.new(     "localhost", 27017, :op_timeout => 3, :connect_timeout => 3   ).db("mongoid_database") end 
Comments
Post a Comment