在我的理解中,当查询超过它的分配时间时,maxTimeMS应该立即终止查询(+ - 2,3秒).但是,mongo并没有立即查询并占用太多时间.
输出currentOp()之后可以看到这一点
{"inprog":[{"opid":176078308,"active":true,"secs_running":105,"op":"query","ns":"xxx","query":{"aggregate": "推文","管道":[{"$ match":{"gTs":{"$ lte":ISODate("2014-07-25T22:00:00Z"),"$ gte":ISODate("2014 -07-20T21:00:00Z")},"RE_H":{"$ in":[NumberLong("884327843395156951")]}}},{"$ match":{"$ and":[{"l ":{"$ in":["bandra","mumbai","thane","bombay","mahim"]}},{"ts":{"$ lte":ISODate("2014-07- 25T21:16:00Z"),"$ gte":ISODate("2014-07-20T21:16:00Z")}}]}},{"$ project":{"!" :1,"s":1,"nR":1,"ts":1}}],"光标":{
},
"maxTimeMS" : 60000
},
"client" : "xxx.xxx.xxx.xxx",
"desc" : "conn56556",
"threadId" : "0x7f96e1cf6700",
"connectionId" : 56556,
"waitingForLock" : false,
"numYields" : 4111,
"lockStats" : {
"timeLockedMicros" : {
"r" : NumberLong(16472467),
"w" : NumberLong(0)
},
"timeAcquiringMicros" : {
"r" : NumberLong(106194),
"w" : NumberLong(0)
}
}
}
]
Run Code Online (Sandbox Code Playgroud)
}
此查询的maxTimeMS为60秒(60,000毫秒),持续105秒.在我看来,这太荒谬了.Mongo在60秒内不应超过2,3秒才能杀死它.
有人可以确认这是否是Mongo的预期行为?
是的,这可能是预期的行为.测量的两次有些不同,secs_running是运行的总耗用时间,而maxTimeMS是实际运行时间:
currentOp.secs_running
以秒为单位的操作持续时间.MongoDB通过从操作的开始时间减去当前时间来计算此值.
http://docs.mongodb.org/manual/reference/method/db.currentOp/
cursor.maxTimeMS()定义
2.6版中的新功能.
cursor.maxTimeMS()
Run Code Online (Sandbox Code Playgroud)Specifies a cumulative time limit in milliseconds for processing operations on a cursor.
和
光标的空闲时间不会影响其处理时间.
http://docs.mongodb.org/manual/reference/method/cursor.maxTimeMS/#cursor.maxTimeMS
您可以同时运行其他进程,因此在极端情况下,许多重要的查询/更新将继续,secs_running可能比期望的maxTimeMS大得多.在你的情况下,numYields为4111表示它产生4111次处理,在此期间经过的时间增加但处理时间没有.
| 归档时间: |
|
| 查看次数: |
2395 次 |
| 最近记录: |