From 16c854e36dd3133484dd950f7538116462f5a9d2 Mon Sep 17 00:00:00 2001 From: Honghua Zhu Date: Sun, 12 Mar 2023 16:43:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=94=81=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transaction/aote/AOTransaction.java | 20 +++++++++---------- .../common/resources/_messages_en.prop | 2 +- .../common/resources/_messages_zh.prop | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lealone-aote/src/main/java/org/lealone/transaction/aote/AOTransaction.java b/lealone-aote/src/main/java/org/lealone/transaction/aote/AOTransaction.java index 9c7c0e937..12809773a 100644 --- a/lealone-aote/src/main/java/org/lealone/transaction/aote/AOTransaction.java +++ b/lealone-aote/src/main/java/org/lealone/transaction/aote/AOTransaction.java @@ -308,14 +308,12 @@ public void checkTimeout() { if (lockedBy != null && lockStartTime != 0 && System.currentTimeMillis() - lockStartTime > session.getLockTimeout()) { boolean isDeadlock = false; - WaitingTransaction waitingTransaction = null; LinkedList 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 diff --git a/lealone-common/src/main/resources/org/lealone/common/resources/_messages_en.prop b/lealone-common/src/main/resources/org/lealone/common/resources/_messages_en.prop index 1d235fd39..d3d146c55 100644 --- a/lealone-common/src/main/resources/org/lealone/common/resources/_messages_en.prop +++ b/lealone-common/src/main/resources/org/lealone/common/resources/_messages_en.prop @@ -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} diff --git a/lealone-common/src/main/resources/org/lealone/common/resources/_messages_zh.prop b/lealone-common/src/main/resources/org/lealone/common/resources/_messages_zh.prop index 0b75f382d..77e13d76b 100644 --- a/lealone-common/src/main/resources/org/lealone/common/resources/_messages_zh.prop +++ b/lealone-common/src/main/resources/org/lealone/common/resources/_messages_zh.prop @@ -176,4 +176,4 @@ HY000=常规错误: {0} HY004=位置数据类型: {0} HYC00=不支持的特性: {0} -HYT00=尝试锁定行 {0} 的时候超时 +HYT00=尝试锁对象 {0} 的时候超时. 详情: {1}