提交 0d81945f authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

add exclusive/shared mode of attempted lock to deadlock details message for improved debugging

上级 670bf2bc
......@@ -160,7 +160,7 @@ public class MVTable extends TableBase {
ArrayList<Session> sessions = checkDeadlock(session, null, null);
if (sessions != null) {
throw DbException.get(ErrorCode.DEADLOCK_1,
getDeadlockDetails(sessions));
getDeadlockDetails(sessions, exclusive));
}
} else {
// check for deadlocks from now on
......@@ -239,7 +239,7 @@ public class MVTable extends TableBase {
return false;
}
private static String getDeadlockDetails(ArrayList<Session> sessions) {
private static String getDeadlockDetails(ArrayList<Session> sessions, boolean exclusive) {
// We add the thread details here to make it easier for customers to
// match up these error messages with their own logs.
StringBuilder buff = new StringBuilder();
......@@ -249,6 +249,7 @@ public class MVTable extends TableBase {
buff.append("\nSession ").append(s.toString())
.append(" on thread ").append(thread.getName())
.append(" is waiting to lock ").append(lock.toString())
.append(exclusive ? " (exclusive)" : " (shared)")
.append(" while locking ");
int i = 0;
for (Table t : s.getLocks()) {
......
......@@ -490,7 +490,7 @@ public class RegularTable extends TableBase {
if (checkDeadlock) {
ArrayList<Session> sessions = checkDeadlock(session, null, null);
if (sessions != null) {
throw DbException.get(ErrorCode.DEADLOCK_1, getDeadlockDetails(sessions));
throw DbException.get(ErrorCode.DEADLOCK_1, getDeadlockDetails(sessions, exclusive));
}
} else {
// check for deadlocks from now on
......@@ -566,7 +566,7 @@ public class RegularTable extends TableBase {
}
return false;
}
private static String getDeadlockDetails(ArrayList<Session> sessions) {
private static String getDeadlockDetails(ArrayList<Session> sessions, boolean exclusive) {
// We add the thread details here to make it easier for customers to
// match up these error messages with their own logs.
StringBuilder buff = new StringBuilder();
......@@ -579,6 +579,7 @@ public class RegularTable extends TableBase {
append(thread.getName()).
append(" is waiting to lock ").
append(lock.toString()).
append(exclusive ? " (exclusive)" : " (shared)").
append(" while locking ");
int i = 0;
for (Table t : s.getLocks()) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论