Mongodb: high acquire database lock
Asked Answered
L

1

7

I face a problem which connected with MongoDb performance. Queries are tens of seconds and by means of command db.currentOp() I can see, that all my queries are waiting database lock. For example:

just simple query

"desc" : "conn36316",
"threadId" : "7420",
"connectionId" : 36316,
"client" : "127.0.0.1:34538",
"active" : true,
"opid" : 197242270,
"secs_running" : 190,
"microsecs_running" : NumberLong(190574655),
"op" : "query",
"ns" : "db.items",
"query" : {
    "find" : "items",
    "filter" : {
        "$msg" : "query not recording (too large)"
    }
},
"numYields" : 92,
"locks" : {
    "Global" : "r",
    "Database" : "r"
},
"waitingForLock" : true,
"lockStats" : {
    "Global" : {
        "acquireCount" : {
            "r" : NumberLong(186)
        },
        "acquireWaitCount" : {
            "r" : NumberLong(1)
        },
        "timeAcquiringMicros" : {
            "r" : NumberLong(24392)
        }
    },
    "Database" : {
        "acquireCount" : {
            "r" : NumberLong(93)
        },
        "acquireWaitCount" : {
            "r" : NumberLong(53)
        },
        "timeAcquiringMicros" : {
            "r" : NumberLong(60099891)
        }
    },
    "Collection" : {
        "acquireCount" : {
            "r" : NumberLong(92)
        }
    }
}

build index query

 "desc" : "TTLMonitor",
 "threadId" : "12592",
 "active" : true,
 "opid" : 958,
 "op" : "none",
 "ns" : "",
 "query" : {

 },
 "numYields" : 0,
 "locks" : {
         "Global" : "r",
         "Database" : "r"
 },
 "waitingForLock" : true,
 "lockStats" : {
         "Global" : {
                 "acquireCount" : {
                         "r" : NumberLong(4)
                 }
         },
         "Database" : {
                 "acquireCount" : {
                         "r" : NumberLong(2)
                 },
                 "acquireWaitCount" : {
                         "r" : NumberLong(1)
                 },
                 "timeAcquiringMicros" : {
                         "r" : NumberLong("3571165481")
                 }
         },
         "Collection" : {
                 "acquireCount" : {
                         "r" : NumberLong(3)
                 }
         }
 }

As you can see waiting for acquiring lock takes enormous time. For common query it equals 60 sec., and for index it equals 3571 sec.!

My work computer can create similar index much faster that it can be create on server.

My server is virtual machine with 10 cores, 40GB of memory and disk is raid1 array.

I'm using MongoDb version 3.2.6 (WiredTiger).

What could be the problem? How can I diagnose the problem?

Lozenge answered 23/6, 2016 at 7:43 Comment(3)
How did you fix this issue ?Guff
Having this same issue.Aetiology
In my case, slow drives were to blameLozenge
L
1

My problem was the low speed disk subsystem, the replacement of the ssd according to the official documentation solved the problem

Lozenge answered 7/7, 2019 at 9:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.