MongoDB 击杀不朽游标

MongoDB kills immortal cursors

我正在使用 PHP mongodb/mongodb 驱动程序 v 1.1.2

底层驱动信息:

mongodb version => 1.1.7
mongodb stability => stable
libmongoc version => 1.3.5
libbson version => 1.3.5

MongoDB 3.4.7 和 3.4.10

连接选项:

socketTimeoutMS=3600000

光标选项:

maxTimeMs: 360000
noCursorTimeout: true

所以我假设光标一定是不朽的

程序 运行 正常,然后崩溃并出现以下错误:

[29-Nov-2017 15:23:04 UTC] PHP Fatal error:  Uncaught MongoDB\Driver\Exception\RuntimeException: Cursor not found (namespace: 'xxxx.yyyy', id: 6220790657981310420).

我在 mongos 日志中看到

2017-11-29T15:21:12.025+0000 I QUERY    [ClusterCursorCleanupJob] Marking cursor id 6220790657981310420 for deletion, idle since 2017-11-29T15:11:11.139+0000
2017-11-29T15:21:16.026+0000 I QUERY    [ClusterCursorCleanupJob] Marking cursor id 6220790657981310420 for deletion, idle since 2017-11-29T15:11:11.139+0000
2017-11-29T15:21:20.026+0000 I QUERY    [ClusterCursorCleanupJob] Marking cursor id 6220790657981310420 for deletion, idle since 2017-11-29T15:11:11.139+0000
...
2017-11-29T15:22:56.029+0000 I QUERY    [ClusterCursorCleanupJob] Marking cursor id 6220790657981310420 for deletion, idle since 2017-11-29T15:11:11.139+0000
2017-11-29T15:23:00.029+0000 I QUERY    [ClusterCursorCleanupJob] Marking cursor id 6220790657981310420 for deletion, idle since 2017-11-29T15:11:11.139+0000
2017-11-29T15:23:04.029+0000 I QUERY    [ClusterCursorCleanupJob] Marking cursor id 6220790657981310420 for deletion, idle since 2017-11-29T15:11:11.139+0000

请注意,"idle since" 时间戳对于所有行都是相同的。我很确定该程序正在积极地从该游标中获取数据。

我不知道游标创建的确切时间,但不早于 15:03:35。

这个问题很少见。我有很多活动光标,其中一些可以使用数小时。这个20分钟后就清理干净了

唯一支持的集合选项是

  • 阅读关注
  • 阅读偏好
  • typeMap
  • 写关注

DocsRef

maxTimeMSnoCursorTimeoutCursor 的选项。您需要在 find() 和类似命令中传递它们。

DocsRef