提交 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 ...@@ -32,6 +32,8 @@ Change Log
engines on a per-DB basis. engines on a per-DB basis.
</li><li>When running the Recover tool on very large (>6G) databases, some statistics were reported with </li><li>When running the Recover tool on very large (>6G) databases, some statistics were reported with
negative numbers. 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> </li></ul>
<h2>Version 1.3.173 (2013-07-28)</h2> <h2>Version 1.3.173 (2013-07-28)</h2>
......
...@@ -1382,6 +1382,10 @@ public class Session extends SessionWithState { ...@@ -1382,6 +1382,10 @@ public class Session extends SessionWithState {
closeTemporaryResults(); closeTemporaryResults();
} }
public int getUndoLogSize() {
return undoLog.size();
}
/** /**
* Represents a savepoint (a position in a transaction to where one can roll * Represents a savepoint (a position in a transaction to where one can roll
* back to). * back to).
......
...@@ -488,7 +488,8 @@ public class MetaTable extends Table { ...@@ -488,7 +488,8 @@ public class MetaTable extends Table {
"USER_NAME", "USER_NAME",
"SESSION_START", "SESSION_START",
"STATEMENT", "STATEMENT",
"STATEMENT_START" "STATEMENT_START",
"UNDO_LOG_SIZE"
); );
break; break;
} }
...@@ -1547,7 +1548,9 @@ public class MetaTable extends Table { ...@@ -1547,7 +1548,9 @@ public class MetaTable extends Table {
// STATEMENT // STATEMENT
command == null ? null : command.toString(), command == null ? null : command.toString(),
// STATEMENT_START // STATEMENT_START
new Timestamp(start).toString() new Timestamp(start).toString(),
// UNDO_LOG_SIZE
"" + s.getUndoLogSize()
); );
} }
} }
......
...@@ -50,6 +50,7 @@ public class TestMetaData extends TestBase { ...@@ -50,6 +50,7 @@ public class TestMetaData extends TestBase {
testStatic(); testStatic();
testGeneral(); testGeneral();
testAllowLiteralsNone(); testAllowLiteralsNone();
testSessions();
} }
private void testColumnResultSetMeta() throws SQLException { private void testColumnResultSetMeta() throws SQLException {
...@@ -971,4 +972,24 @@ public class TestMetaData extends TestBase { ...@@ -971,4 +972,24 @@ public class TestMetaData extends TestBase {
deleteDb("metaData"); 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论