Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb: high acquire database lock

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?

like image 270
lga Avatar asked Jun 23 '16 07:06

lga


1 Answers

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

like image 190
lga Avatar answered Nov 03 '22 19:11

lga