小编imj*_*osh的帖子

MongoDB CursorNotFound Error on collection.find() 几百个小记录

我正在使用本机 Node JS 驱动程序(v. 3.0.10)在 Mongo 3.6.6(在一个小的 Mongo Atlas 集群上,未分片)上运行

我的代码如下所示:

const records = await collection.find({
  userId: ObjectId(userId),
  status: 'completed',
  lastUpdated: {
    $exists: true,
    $gte: '2018-06-10T21:24:12.000Z'
  }
}).toArray();
Run Code Online (Sandbox Code Playgroud)

我偶尔会看到这个错误:

{
  "name": "MongoError",
  "message": "cursor id 16621292331349 not found",
  "ok": 0,
  "errmsg": "cursor id 16621292331349 not found",
  "code": 43,
  "codeName": "CursorNotFound",
  "operationTime": "6581469650867978275",
  "$clusterTime": {
    "clusterTime": "6581469650867978275",
    "signature": {
      "hash": "aWuGeAxOib4XWr1AOoowQL8yBmQ=",
      "keyId": "6547661618229018626"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这发生在最多返回几百条记录的查询中。每个记录有几百个字节。

我在网上找了什么问题可能是,但大部分东西发现在谈论光标超时对于需要超过10分钟的时间才能完成非常大的操作。我无法从我的日志中确切地说出失败的查询花费了多长时间,但最多只有两秒(可能比这短得多)。

我测试使用与出错的值相同的值运行查询,执行时间explain仅为几毫秒:

"executionStats" : {
    "executionSuccess" …
Run Code Online (Sandbox Code Playgroud)

mongodb node.js

4
推荐指数
1
解决办法
2209
查看次数

标签 统计

mongodb ×1

node.js ×1