i think i found this connection from currentOp(): “connectionId” : NumberLong(54)
because this connection holds a w lock of a collection, and i only have one write operation in my cluster.
but how to find the uncommit sql of this connection? and how to find which collection lock it holds.
the client is :“client” : “127.0.0.1:43186”, i can find pid using netstat -nap
{
"shard" : "rs_shard03",
"type" : "idleSession",
"host" : "redhat07:31018",
"desc" : "inactive transaction",
"client_s" : "192.168.17.160:35562",
"connectionId" : NumberLong(54),
"appName" : "MongoDB Shell",
"clientMetadata" : {
"application" : {
"name" : "MongoDB Shell"
},
"driver" : {
"name" : "MongoDB Internal Client",
"version" : "5.0.4"
},
"os" : {
"type" : "Linux",
"name" : "Red Hat Enterprise Linux release 8.2 (Ootpa)",
"architecture" : "x86_64",
"version" : "Kernel 4.18.0-193.el8.x86_64"
},
"mongos" : {
"host" : "redhat04:32017",
"client" : "127.0.0.1:43186",
"version" : "5.0.4"
}
},
"lsid" : {
"id" : UUID("21e7cf7d-550e-4483-82a3-d1b945359d4a"),
"uid" : BinData(0,"O0CMtIVItQN4IsEOsJdrPL8s7jv5xwh5a/A5Qfvs2A8=")
},
"transaction" : {
"parameters" : {
"txnNumber" : NumberLong(0),
"autocommit" : false,
"readConcern" : {
"provenance" : "implicitDefault"
}
},
"readTimestamp" : Timestamp(0, 0),
"startWallClockTime" : "2022-03-18T11:04:59.023+08:00",
"timeOpenMicros" : NumberLong(11935923),
"timeActiveMicros" : NumberLong(242),
"timeInactiveMicros" : NumberLong(11935681),
"expiryTime" : "2022-03-18T11:05:59.023+08:00"
},
"waitingForLock" : false,
"active" : false,
"locks" : {
"ReplicationStateTransition" : "w",
"Global" : "w",
"Database" : "w",
"Collection" : "w"
},
"lockStats" : {
"ReplicationStateTransition" : {
"acquireCount" : {
"w" : NumberLong(5)
}
},
"Global" : {
"acquireCount" : {
"r" : NumberLong(1),
"w" : NumberLong(2)
}
},
"Database" : {
"acquireCount" : {
"w" : NumberLong(2)
}
},
"Collection" : {
"acquireCount" : {
"w" : NumberLong(2)
}
},
"Mutex" : {
"acquireCount" : {
"r" : NumberLong(6)
}
}
}
},
{
"shard" : "rs_shard03",
"client_s" : "192.168.17.160:35562",
"host" : "redhat07:31018",
"connectionId" : NumberLong(54),
"appName" : "MongoDB Shell",
"clientMetadata" : {
"application" : {
"name" : "MongoDB Shell"
},
"driver" : {
"name" : "MongoDB Internal Client",
"version" : "5.0.4"
},
"os" : {
"type" : "Linux",
"name" : "Red Hat Enterprise Linux release 8.2 (Ootpa)",
"architecture" : "x86_64",
"version" : "Kernel 4.18.0-193.el8.x86_64"
},
"mongos" : {
"host" : "redhat04:32017",
"client" : "127.0.0.1:43186",
"version" : "5.0.4"
}
},
"desc" : "transaction coordinator",
"twoPhaseCommitCoordinator" : {
"lsid" : {
"id" : UUID("21e7cf7d-550e-4483-82a3-d1b945359d4a"),
"uid" : BinData(0,"O0CMtIVItQN4IsEOsJdrPL8s7jv5xwh5a/A5Qfvs2A8=")
},
"txnNumber" : NumberLong(0),
"state" : "inactive",
"commitStartTime" : ISODate("2022-03-18T03:04:59.023Z"),
"hasRecoveredFromFailover" : false,
"stepDurations" : {
},
"deadline" : ISODate("2022-03-18T03:05:59.023Z")
}
},
{
"shard" : "rs_shard01",
"type" : "op",
"host" : "redhat04:29017",
"desc" : "conn39",
"connectionId" : 39,
"client_s" : "192.168.17.160:53680",
"clientMetadata" : {
"driver" : {
"name" : "NetworkInterfaceTL",
"version" : "5.0.4"
},
"os" : {
"type" : "Linux",
"name" : "Red Hat Enterprise Linux release 8.2 (Ootpa)",
"architecture" : "x86_64",
"version" : "Kernel 4.18.0-193.el8.x86_64"
}
},
"active" : true,
"currentOpTime" : "2022-03-18T11:05:10.952+08:00",
"effectiveUsers" : [
{
"user" : "__system",
"db" : "local"
}
],
"threaded" : true,
"opid" : "rs_shard01:9386",
"secs_running" : NumberLong(8),
"microsecs_running" : NumberLong(8054728),
"op" : "command",
"ns" : "admin.$cmd",
"command" : {
"isMaster" : 1,
"maxAwaitTimeMS" : NumberLong(10000),
"topologyVersion" : {
"processId" : ObjectId("6233f50d280370f6306ff001"),
"counter" : NumberLong(6)
},
"internalClient" : {
"minWireVersion" : 13,
"maxWireVersion" : 13
},
"maxTimeMSOpOnly" : NumberLong(20000),
"$db" : "admin"
},
"numYields" : 0,
"waitingForLatch" : {
"timestamp" : ISODate("2022-03-18T03:05:02.998Z"),
"captureName" : "AnonymousLockable"
},
"locks" : {
},
"waitingForLock" : false,
"lockStats" : {
},
"waitingForFlowControl" : false,
"flowControlStats" : {
}
},