Skip to content

Commit

Permalink
调整锁超时的错误提示内容
Browse files Browse the repository at this point in the history
  • Loading branch information
codefollower committed Mar 12, 2023
1 parent 5ce1609 commit 16c854e
Showing 3 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -308,14 +308,12 @@ public void checkTimeout() {
if (lockedBy != null && lockStartTime != 0
&& System.currentTimeMillis() - lockStartTime > session.getLockTimeout()) {
boolean isDeadlock = false;
WaitingTransaction waitingTransaction = null;
LinkedList<WaitingTransaction> waitingTransactions = waitingTransactionsRef.get();
if (waitingTransactions == null)
return;
for (WaitingTransaction wt : waitingTransactions) {
if (wt.getTransaction() == lockedBy) {
isDeadlock = true;
waitingTransaction = wt;
break;
}
}
@@ -329,23 +327,23 @@ public void checkTimeout() {
break;
}
}
String keyStr = waitingTransaction2.getKey().toString();
if (isDeadlock) {
String msg = getMsg(transactionId, session, lockedBy, waitingTransaction2);
msg += "\r\n"
+ getMsg(lockedBy.transactionId, lockedBy.session, this, waitingTransaction);
String msg = getMsg(transactionId, session, lockedBy);
msg += "\r\n" + getMsg(lockedBy.transactionId, lockedBy.session, this);

msg += ", the locked object: " + keyStr;
throw DbException.get(ErrorCode.DEADLOCK_1, msg);
} else {
String msg = getMsg(transactionId, session, lockedBy, waitingTransaction2);
throw DbException.get(ErrorCode.LOCK_TIMEOUT_1, msg);
String msg = getMsg(transactionId, session, lockedBy);
throw DbException.get(ErrorCode.LOCK_TIMEOUT_1, keyStr, msg);
}
}
}

private static String getMsg(long tid, Session session, AOTransaction transaction,
WaitingTransaction waitingTransaction) {
private static String getMsg(long tid, Session session, AOTransaction transaction) {
return "transaction #" + tid + " in session " + session + " wait for transaction #"
+ transaction.transactionId + " in session " + transaction.session + ", key: "
+ waitingTransaction.getKey();
+ transaction.transactionId + " in session " + transaction.session;
}

@Override
Original file line number Diff line number Diff line change
@@ -176,4 +176,4 @@
HY000=General error: {0}
HY004=Unknown data type: {0}
HYC00=Feature not supported: {0}
HYT00=Timeout trying to lock row {0}
HYT00=Timeout trying to lock object: {0}. Details: {1}
Original file line number Diff line number Diff line change
@@ -176,4 +176,4 @@
HY000=常规错误: {0}
HY004=位置数据类型: {0}
HYC00=不支持的特性: {0}
HYT00=尝试锁定行 {0} 的时候超时
HYT00=尝试锁对象 {0} 的时候超时. 详情: {1}

0 comments on commit 16c854e

Please sign in to comment.