提交 63a2efdb authored 作者: Thomas Mueller's avatar Thomas Mueller

Temp tables: sometimes a database could not recover normally.

上级 aae8c13d
......@@ -144,7 +144,7 @@ public class PageBtreeIndex extends PageIndex {
store.update(empty);
return empty;
} else if (!(p instanceof PageBtree)) {
throw DbException.throwInternalError("" + p);
throw DbException.get(ErrorCode.FILE_CORRUPTED_1, "" + p);
}
return (PageBtree) p;
}
......
......@@ -210,14 +210,16 @@ public class PageDataIndex extends PageIndex {
*/
PageData getPage(int id, int parent) {
Page pd = store.getPage(id);
PageData p = (PageData) pd;
if (p == null) {
if (pd == null) {
PageDataLeaf empty = PageDataLeaf.create(this, id, parent);
// could have been created before, but never committed
store.logUndo(empty, null);
store.update(empty);
return empty;
} else if (!(pd instanceof PageData)) {
throw DbException.get(ErrorCode.FILE_CORRUPTED_1, "" + pd);
}
PageData p = (PageData) pd;
if (parent != -1) {
if (p.getParentPageId() != parent) {
throw DbException.throwInternalError(p + " parent " + p.getParentPageId() + " expected " + parent);
......
......@@ -292,6 +292,11 @@ public class PageLog {
int sessionId = in.readVarInt();
int tableId = in.readVarInt();
long key = in.readVarLong();
if (stage == RECOVERY_STAGE_UNDO && tableId == -1) {
// immediately commit,
// because the pages may be re-used
setLastCommitForSession(sessionId, logId, pos);
}
if (stage == RECOVERY_STAGE_REDO) {
if (isSessionCommitted(sessionId, logId, pos)) {
if (trace.isDebugEnabled()) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论