提交 c1844be3 authored 作者: noelgrandin's avatar noelgrandin

Add an UNDO_LOG_SIZE column to the SESSIONS metadata table, to allow detecting when rogue

sessions are creating large transactions.
上级 4b0906e9
......@@ -32,6 +32,8 @@ Change Log
engines on a per-DB basis.
</li><li>When running the Recover tool on very large (>6G) databases, some statistics were reported with
negative numbers.
</li><li>Add an UNDO_LOG_SIZE column to the SESSIONS metadata table, to allow detecting when rogue
sessions are creating large transactions.
</li></ul>
<h2>Version 1.3.173 (2013-07-28)</h2>
......
......@@ -1382,6 +1382,10 @@ public class Session extends SessionWithState {
closeTemporaryResults();
}
public int getUndoLogSize() {
return undoLog.size();
}
/**
* Represents a savepoint (a position in a transaction to where one can roll
* back to).
......
......@@ -488,7 +488,8 @@ public class MetaTable extends Table {
"USER_NAME",
"SESSION_START",
"STATEMENT",
"STATEMENT_START"
"STATEMENT_START",
"UNDO_LOG_SIZE"
);
break;
}
......@@ -1547,7 +1548,9 @@ public class MetaTable extends Table {
// STATEMENT
command == null ? null : command.toString(),
// STATEMENT_START
new Timestamp(start).toString()
new Timestamp(start).toString(),
// UNDO_LOG_SIZE
"" + s.getUndoLogSize()
);
}
}
......
......@@ -50,6 +50,7 @@ public class TestMetaData extends TestBase {
testStatic();
testGeneral();
testAllowLiteralsNone();
testSessions();
}
private void testColumnResultSetMeta() throws SQLException {
......@@ -971,4 +972,24 @@ public class TestMetaData extends TestBase {
deleteDb("metaData");
}
private void testSessions() throws SQLException {
Connection conn = getConnection("metaData");
conn.setAutoCommit(false);
Statement stat = conn.createStatement();
stat.execute("create table test(id int)");
stat.execute("begin transaction");
for (int i = 0; i < 6; i++) {
stat.execute("insert into test values (1)");
}
ResultSet rs = stat.executeQuery("select undo_log_size from INFORMATION_SCHEMA.SESSIONS");
rs.next();
assertEquals(6, rs.getInt(1));
rs.close();
stat.execute("commit");
rs = stat.executeQuery("select undo_log_size from INFORMATION_SCHEMA.SESSIONS");
rs.next();
assertEquals(0, rs.getInt(1));
conn.close();
deleteDb("metaData");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论