jon*_*iba 19 mongodb node.js mongodb-indexes
编辑:基本上我正在寻找一些关于如何理解我的MongoDB实例上运行的后台操作的提示,并可能在必要时减少/禁用它们,这样它们就不会干扰运行测试.我已经尝试了mongostat
,mongotop
但没有找到任何与他们相关的东西,这有助于我了解正在运行的后台操作以及启动它们的内容.db.currentOp()
在我开始运行测试之前运行时始终返回一个空数组.
我在使用node(mocha,cucumber)开发时经常运行测试.从昨天开始,大约25%的服务器初始化尝试连接到mongodb失败,出现以下错误:
**Unhandled rejection MongoError: exception: cannot perform operation: a background operation is currently running for collection** somecollection
at Function.MongoError.create (/somepath/node_modules/pow-mongodb-fixtures/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:31:11)
at /somepath/node_modules/pow-mongodb-fixtures/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:793:66
at bound (domain.js:254:14)
at runBound (domain.js:267:12)
at Callbacks.emit (.../node_modules/pow-mongodb-fixtures/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:94:3)
at null.messageHandler (/somepath/node_modules/pow-mongodb-fixtures/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:235:23)
at Socket.<anonymous> (/somepath/node_modules/pow-mongodb-fixtures/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:294:20)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:538:20)
Run Code Online (Sandbox Code Playgroud)
我们使用pow-mongodb-fixture来清除db并在运行测试之前用一些基本数据填充它,这就是发生这种情况的地方.当这种情况开始发生时,AFAIK并未发生重大变化.有什么想法,我甚至可以开始研究这个错误的来源?
好吧,我不打算将此作为答案,因为我正在寻找一种方法来监控正在发生的事情并通过mongo db找出问题.不过,我确实弄明白了这个问题.这不是世界上最有用的解决方案,但事实证明我们是异步启动服务器,它将运行所有mongoose模式,从而检查/重新创建所有索引,并且或多或少同时运行fixtures代码以清除我的集合.
简而言之,在创建索引时不要尝试删除集合:)
在这种情况下,您的朋友将是:
db.currentOp(true)
Run Code Online (Sandbox Code Playgroud)
指定 true 包括对空闲连接和系统操作的操作。
请参阅此处:https : //docs.mongodb.org/manual/reference/method/db.currentOp/
归档时间: |
|
查看次数: |
3288 次 |
最近记录: |