怎么查询当前正在等待锁的写操作?



  • 如题,怎么查询当前正在等待锁的写操作?


  • Lv 1

    1:查看MongoDB當前正在做哪些操作?

    db.currentOp()

    等同於:

    db.$cmd.sys.inprog.findOne()

    2:查看當前有多少個連接?

    db.serverStatus().connections

     

    3:詳解currentOp()

    gechongrepl:PRIMARY> db.currentOp()

    {

            "inprog" : [

                   {

                           "opid" : 6222,

                           "active" : true,

                           "secs_running" : 3,

                           "microsecs_running" : NumberLong(3662328),

                           "op" : "getmore",

                           "ns" : "local.oplog.rs",

                           "query" : {

                                  

                           },

                           "client" : "192.168.91.132:45745",

                           "desc" : "conn5",

                           "threadId" : "0x7f1370cb4700",

                           "connectionId" : 5,

                           "waitingForLock" : false,

                           "numYields" : 0,

                           "lockStats" : {

                                   "timeLockedMicros" : {

                                          "r" : NumberLong(141),

                                          "w" : NumberLong(0)

                                   },

                                   "timeAcquiringMicros" : {

                                          "r" : NumberLong(16),

                                          "w" : NumberLong(0)

                                   }

                           }

                   }

            ]

    }

    "opid" : 6222,#進程號 "active" : true,#是否活動狀態 "secs_running" : 3,#操作運行了多少秒 "microsecs_running" : NumberLong(3662328), "op" : "getmore",#操作類型,包括(insert/query/update/remove/getmore/command) "ns" : "local.oplog.rs",#命名空間 "query" : {},#如果op是查詢操作,這裡將顯示查詢內容;也有說這裡顯示具體的動作陳述式的

    "client" : "192.168.91.132:45745",#連接的用戶端資訊 "desc" : "conn5",#資料庫的連接資訊 "threadId" : "0x7f1370cb4700",#執行緒ID "connectionId" : 5,#資料庫的連接ID "waitingForLock" : false,#是否等待獲取鎖 "numYields" : 0, "lockStats" : { "timeLockedMicros" : {#持有的鎖時間微秒 "r" : NumberLong(141),#整個MongoDB實例的全域讀鎖 "w" : NumberLong(0)},#整個MongoDB實例的全域寫鎖 "timeAcquiringMicros" : {#為了獲得鎖,等待的微秒時間 "r" : NumberLong(16),#整個MongoDB實例的全域讀鎖 "w" : NumberLong(0)}#整個MongoDB實例的全域寫鎖

     

     


登录后回复
 

与 萌阔论坛 的连接断开,我们正在尝试重连,请耐心等待