MongoDB: How to disable logging the warning: ClientCursor::staticYield can't unlock b/c of recursive lock?

五迷三道 提交于 2019-12-23 13:15:20

问题


I get the warning stated in the title

warning: ClientCursor::staticYield can't unlock b/c of recursive lock ns....

in the log file for literally gazillion of times (the log file reaches 200 GB in size in a single day with this single log message). As mentioned in this SO question, I want to adopt the "solution" of simply ignoring the message.

What I did (to no avail) to stop it is to:

  • set the param quiet = true
  • set the param oplog = 0
  • set the param logpath=/dev/null (hoping that nothing gets logged anymore)
  • set the param logappend=false

All of the above are useless - the message still floods the log file.

The solution I use now is to run a cron job every night to simply empty that log file.

Please, is there anything else I can try?

I use MongoDB 2.6.2 on a Debian 6.0 while programming it from Perl


回答1:


I have recently been looking into this error myself as I was seeing 25Gb a month generated from mongod.log with a similar message. However, I noticed that a query was included in the log message (I've formatted the message to fit in this post, it was actually all on one line):

warning: ClientCursor::yield can't unlock b/c of recursive lock ns: my-database.users top:
{
    opid: 1627436260,
    active: true,
    secs_running: 0,
    op: "query",
    ns: "my-database",
    query:
    {
        findAndModify: "users",
        query: { Registered: false, Completed: 0 },
        sort: { Created: 1 },
        update: { $set: { NextRefresh: "2014-12-07" } },
        new: true
    },
    client: "10.1.34.175:53582",
    desc: "conn10906412",
    threadId: "0x7f824f0f9700",
    connectionId: 10906412,
    locks: { ^: "w", ^my-database: "W" },
    waitingForLock: false,
    numYields: 0,
    lockStats: { timeLockedMicros: {}, timeAcquiringMicros: { r: 0, w: 3 } }
}

A bit of Googling revealed that this message is most commonly raised when the query cannot use any indexes. I tried using .explain() with the query in the log and sure enough it showed that a BasicCursor was being used with no index:

db.users.find( { Registered: false, Completed: 0 } ).sort( { Created: 1 } ).explain()
{
    "cursor" : "BasicCursor",
    "isMultiKey" : false,
    "n" : 0,
    "nscannedObjects" : 10453,
    "nscanned" : 10453,
    "nscannedObjectsAllPlans" : 10453,
    "nscannedAllPlans" : 10453,
    "scanAndOrder" : true,
    "indexOnly" : false,
    "nYields" : 1,
    "nChunkSkips" : 0,
    "millis" : 7,
    "indexBounds" : {

    },
    "server" : "mongodb-live.eu-west-1a.10_1_2_213:27017"
}

Adding an index for the elements in the query fixed the issue. The log was no longer generated and when I ran .explain() again it showed an index being used:

{
    "cursor" : "BtreeCursor Registered_1_Completed_1",
    "isMultiKey" : false,
    "n" : 0,
    "nscannedObjects" : 0,
    "nscanned" : 0,
    "nscannedObjectsAllPlans" : 0,
    "nscannedAllPlans" : 1,
    "scanAndOrder" : true,
    "indexOnly" : false,
    "nYields" : 0,
    "nChunkSkips" : 0,
    "millis" : 0,
    "indexBounds" : {
        "Registered" : [
            [
                false,
                false
            ]
        ],
        "Completed" : [
            [
                0,
                0
            ]
        ]
    },
    "server" : "mongodb-live.eu-west-1a.10_1_2_213:27017"
}


来源:https://stackoverflow.com/questions/24911469/mongodb-how-to-disable-logging-the-warning-clientcursorstaticyield-cant-unl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!