是否有可能在Pymongo中创建一个聚合,没有光标超时? [英] Is it possible to create an aggregation in Pymongo with no timeout for the cursor?
问题描述
res = Things.objects._collection.aggregate(pipeline,
allowDiskUse =真的,
batchSize = 101,
noCursorTimeout = True
)
失败,并失败
lockquote
OperationFailure:无法识别的字段'noCursorTimeout'
从Pymongo文档看来,no_cursor_timeout可以和find()一起使用,但是我一直没有成功找到aggregate()的可比** kwargs。
我不想使用setParameter或maxTimeMS。
更新:
OP_QUERY头中的NoCursorTimeout位阻止服务器关闭闲置超过10分钟的游标。客户可以设置这一点,如果他们可能花费超过10分钟处理一批结果。
聚合和parallelCollectionScan命令应该允许客户端关闭光标超时。
对这张票的回应是:
lockquote
故意不支持noCursorTimeout。当我们实现光标保持活动时,
需要的理由将消失。
工作将在SERVER-6036中进行跟踪。
查看 SERVER-6036 :
- 更新时间:9月14日2016年3月15日下午3点53分05秒GMT + 0000
- 解决方法:未解决
版本/ s:已计划但未计划
如果我已经正确地阅读了文档, ()。
您是正确的,游标超时不能在个别聚合游标上禁用。但是我们提供了一个全局配置设置: cursorTimeoutMillis
,您可以增加到一个很大的数目:
mongod --setParameter cursorTimeoutMillis = 600000#10分钟
参见 SERVER-8188 用于MongoDB版本信息,以及如何在运行时设置该参数。
The aggregation looks like:
res = Things.objects._collection.aggregate(pipeline,
allowDiskUse=True,
batchSize=101,
noCursorTimeout=True
)
and fails with
OperationFailure: unrecognized field 'noCursorTimeout'
It appears from the Pymongo documentation that no_cursor_timeout can be used with find(), however I have been unsuccessful locating a comparable **kwargs for aggregate().
I do not want to use setParameter or maxTimeMS.
UPDATE:
From MongoDB's Jira Site: SERVER-15042
The NoCursorTimeout bit in the OP_QUERY header prevents the server from closing a cursor that's idle for more than 10 minutes. Clients can set this bit if they may spend more than 10 minutes processing a batch of results.
The "aggregate" and "parallelCollectionScan" commands should allow the client to turn off cursor timeouts, too.
The response to this ticket was:
We intentionally do not support noCursorTimeout. The rationale for needing this will go away when we implement cursor keepalive. That work will be tracked in SERVER-6036.
Looking at SERVER-6036:
- Updated: Sep 14 2016 03:53:05 PM GMT+0000
- Status: OPEN
- Resolution: Unresolved
- Fix Version/s: planned but not scheduled
If I have read the documents correctly, a cursor no timeout option does not exist yet for aggregate().
You're correct, cursor timeout can't be disabled on individual aggregation cursors. But we've provided a global config setting, cursorTimeoutMillis
, that you can increase to a large number:
mongod --setParameter cursorTimeoutMillis=600000 # 10 minutes
See SERVER-8188 for MongoDB version info, and how to set this parameter at runtime.
这篇关于是否有可能在Pymongo中创建一个聚合,没有光标超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!