簡體   English   中英

監控MongoDB“后台操作”?

[英]Monitoring MongoDB “background operations”?

編輯:基本上我正在尋找一些關於如何理解我的MongoDB實例上運行的后台操作的提示,並可能在必要時減少/禁用它們,這樣它們就不會干擾運行測試。 我已經嘗試了mongostatmongotop但沒有發現任何與它有關的東西,這些東西幫助我了解了正在運行的后台操作以及啟動它們的內容。 在開始運行測試之前, 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)

我們使用pow-mongodb-fixture來清除db並在運行測試之前用一些基本數據填充它,這就是發生這種情況的地方。 當這種情況開始發生時,AFAIK並未發生重大變化。 有什么想法,我甚至可以開始研究這個錯誤的來源?

好吧,我不打算將此作為答案,因為我正在尋找一種方法來監控正在發生的事情並通過mongo db找出問題。 不過,我確實弄明白了這個問題。 這不是世界上最有用的解決方案,但事實證明我們是異步啟動服務器,它將運行所有mongoose模式,從而檢查/重新創建所有索引,並且或多或少同時運行fixtures代碼以清除我的集合。

簡而言之,在創建索引時不要嘗試刪除集合:)

在這種情況下你的朋友將是:

db.currentOp(true)

指定true包括對空閑連接和系統操作的操作。

請參見: https//docs.mongodb.org/manual/reference/method/db.currentOp/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM