mongo大数据量更新服务端超时解决: Cursor not found, cursor id: 82792803897 mongodb pymongo.errors.CursorNotFound: Cursor not found, cursor id: 82792803897

mongodb pymongo.errors.CursorNotFound: Cursor not found, cursor id: 82792803897

  默认 mongo server维护连接的时间窗口是十分钟

  默认 单次从 server获取数据是101条或者 大于1M小于16M的数据

  所以默认情况下,如果10分钟内未能处理完数据,则抛出该异常。

  解决办法:

  1. 修改每批次获取数据量的条数,即batch size:

  collection.find(condition).batch_size(5)

  批量数需 估算十分钟内能处理的数据量

  2. 延长超时时间 需显示的关闭cursor

    db.getCollection("unicom_jd").find({}).noCursorTimeout()

  默认 mongo server维护连接的时间窗口是十分钟

  默认 单次从 server获取数据是101条或者 大于1M小于16M的数据

  所以默认情况下,如果10分钟内未能处理完数据,则抛出该异常。

  解决办法:

  1. 修改每批次获取数据量的条数,即batch size:

  collection.find(condition).batch_size(5)

  批量数需 估算十分钟内能处理的数据量

  2. 延长超时时间 需显示的关闭cursor

    db.getCollection("unicom_jd").find({}).noCursorTimeout()

猜你喜欢

转载自www.cnblogs.com/CHWLearningNotes/p/10333479.html