0
0 Comments

mongod.log 日志报错信息

2020-09-19T11:01:07.360+0800 W – [conn24692] Caught Assertion while trying to profile msg against prddb.T_DATA: LockTimeout: Unable to acquire lock ‘{15344661382833097947: Metadata, 1509603327550934235}’ within 5ms’ milliseconds

mongodb设置的锁等待时间是默认的5ms,经过测试,如果一个session A开启事物,修改一条数据,不提交,

A

s = db.getMongo().startSession()

s.startTransaction()

s.getDatabase(“prddb”).T_DATA.update({“id”:1000},{“id”:0})

session B开启事物修改同一条数据,mongodb会直接报错

B

s = db.getMongo().startSession()

s.startTransaction()

s.getDatabase(“prddb”).T_DATA.update({“id”:1000},{“id”:0})

报错

WriteCommandError({
“errorLabels” : [
“TransientTransactionError”
],
“operationTime” : Timestamp(1600495472, 1),
“ok” : 0,
“errmsg” : “Transaction 2 has been aborted.”,
“code” : 251,
“codeName” : “NoSuchTransaction”,
“$clusterTime” : {
“clusterTime” : Timestamp(1600495472, 1),
“signature” : {
“hash” : BinData(0,”8qI14/MyzH00dS7GW5V3m1urN50=”),
“keyId” : NumberLong(“6824584737059766273”)
}
}
})

而这个时候 mongod.log不会输出报错日志,当A提交数据,mongod.log才会输出A会话事物的日志信息,然后再进行B的操作才会正常

请问,Caught Assertion while trying to profile msg against prddb.T_DATA: LockTimeout: Unable to acquire lock 这种报错日志是哪一种情况导致的报错,报错的意思是什么?

Edited question