我通过“_id”字段的hash值对一个集合做了分片操作,有7个多G的数据。当我删除这个集合的时候一直出现 LockBusy。
# 操作命令输出
“`
mongos> db.text.drop()
2019-07-01T17:13:19.123+0800 E QUERY [thread1] Error: drop failed: {
“ok” : 0,
“errmsg” : “timed out waiting for DW.text”,
“code” : 46,
“codeName” : “LockBusy”,
“$clusterTime” : {
“clusterTime” : Timestamp(1561972399, 4),
“signature” : {
“hash” : BinData(0,”YF87K9kifZ0zRymuSIZKi8xioG4=”),
“keyId” : NumberLong(“6685238272647495681”)
}
},
“operationTime” : Timestamp(1561972399, 4)
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBCollection.prototype.drop@src/mongo/shell/collection.js:695:1
@(shell):1:1
“`
# 日志输出
“`
2019-07-01T17:03:50.918+0800 I SHARDING [conn553] distributed lock ‘DW-movePrimary’ acquired for ‘dropCollection’, ts : 5d19cc7614bae76037d93e7b
2019-07-01T17:03:50.943+0800 I SHARDING [conn553] distributed lock ‘DW’ acquired for ‘dropCollection’, ts : 5d19cc7614bae76037d93f37
2019-07-01T17:04:02.021+0800 I SHARDING [conn553] waited 11s for distributed lock DW.text for dropCollection
2019-07-01T17:04:10.991+0800 I SHARDING [conn553] distributed lock with ts: 5d19cc7614bae76037d93f37′ unlocked.
2019-07-01T17:04:11.060+0800 I SHARDING [conn553] distributed lock with ts: 5d19cc7614bae76037d93e7b’ unlocked.
“`
我的最终是通过等待锁释放解决的。