提交 5f1bd724 authored 作者: Thomas Mueller's avatar Thomas Mueller

better trace messages

上级 4ae3cdb6
......@@ -21,6 +21,7 @@ import org.h2.engine.Database;
import org.h2.engine.Session;
import org.h2.expression.Expression;
import org.h2.message.Message;
import org.h2.message.Trace;
import org.h2.security.SHA256;
import org.h2.store.DataHandler;
import org.h2.store.FileStore;
......@@ -251,5 +252,9 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
public SmallLRUCache getLobFileListCache() {
return null;
}
public Trace getTrace() {
return session.getDatabase().getTrace(Trace.DATABASE);
}
}
......@@ -2117,4 +2117,8 @@ public class Database implements DataHandler {
return tempFileDeleter;
}
public Trace getTrace() {
return getTrace(Trace.DATABASE);
}
}
......@@ -8,6 +8,7 @@ package org.h2.store;
import java.sql.SQLException;
import org.h2.message.Trace;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.value.Value;
......@@ -151,4 +152,11 @@ public interface DataHandler {
*/
SmallLRUCache getLobFileListCache();
/**
* Get the trace writer.
*
* @return the trace writer
*/
Trace getTrace();
}
......@@ -314,7 +314,7 @@ public class DiskFile implements CacheWriter {
DataInputStream in = new DataInputStream(new ByteArrayInputStream(summary));
int b2 = in.readInt();
if (b2 > fileBlockCount) {
database.getTrace(Trace.DATABASE).info(
getTrace().info(
"unexpected size " + b2 + " when initializing summary for " + fileName + " expected:"
+ fileBlockCount);
return;
......@@ -378,7 +378,7 @@ public class DiskFile implements CacheWriter {
freeUnusedPages();
init = true;
} catch (Throwable e) {
database.getTrace(Trace.DATABASE).error(
getTrace().error(
"error initializing summary for " + fileName + " size:" + summary.length + " stage:" + stage, e);
// ignore - init is still false in this case
}
......@@ -1278,5 +1278,10 @@ public class DiskFile implements CacheWriter {
public String toString() {
return getClass().getName() + ":" + fileName;
}
public Trace getTrace() {
return database.getTrace(Trace.DATABASE);
}
}
......@@ -14,6 +14,7 @@ import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.message.Message;
import org.h2.message.Trace;
import org.h2.security.SecureFileStore;
import org.h2.store.fs.FileObject;
import org.h2.store.fs.FileSystem;
......@@ -454,7 +455,10 @@ public class FileStore {
try {
file.sync();
} catch (IOException e) {
// TODO log exception
Trace trace = handler.getTrace();
if (trace != null) {
trace.error("Sync failed", e);
}
}
}
......
......@@ -119,7 +119,7 @@ public class TableData extends Table implements RecordReader {
// this could happen, for example on failure in the storage
// but if that is not the case it means there is something wrong
// with the database
// TODO log this problem
trace.error("Could not undo operation", e);
throw e2;
}
throw Message.convert(e);
......@@ -209,7 +209,7 @@ public class TableData extends Table implements RecordReader {
// this could happen, for example on failure in the storage
// but if that is not the case it means
// there is something wrong with the database
// TODO log this problem
trace.error("Could not remove index", e);
throw e2;
}
throw e;
......@@ -310,7 +310,7 @@ public class TableData extends Table implements RecordReader {
// this could happen, for example on failure in the storage
// but if that is not the case it means there is something wrong
// with the database
// TODO log this problem
trace.error("Could not undo operation", e);
throw e2;
}
throw Message.convert(e);
......
......@@ -32,6 +32,7 @@ import org.h2.engine.DbObject;
import org.h2.engine.MetaRecord;
import org.h2.log.LogFile;
import org.h2.message.Message;
import org.h2.message.Trace;
import org.h2.result.SimpleRow;
import org.h2.security.SHA256;
import org.h2.store.DataHandler;
......@@ -1043,5 +1044,12 @@ public class Recover extends Tool implements DataHandler {
public TempFileDeleter getTempFileDeleter() {
return TempFileDeleter.getInstance();
}
/**
* INTERNAL
*/
public Trace getTrace() {
return null;
}
}
......@@ -178,7 +178,7 @@ public class Cache2Q implements Cache {
// can't remove any record, because the log is not written yet
// hopefully this does not happen too much, but it could happen
// theoretically
// TODO log this
writer.getTrace().info("Cannot remove records, cache size too small?");
break;
}
if (sizeIn > maxIn) {
......
......@@ -100,7 +100,7 @@ public class CacheLRU implements Cache {
// can't remove any record, because the log is not written yet
// hopefully this does not happen too much, but it could happen
// theoretically
// TODO log this
writer.getTrace().info("Cannot remove records, cache size too small?");
break;
}
CacheObject last = head.next;
......@@ -304,7 +304,7 @@ public class CacheLRU implements Cache {
////System.out.println("cache write "+entry.getPos());
// writer.writeBack(entry);
// } catch(SQLException e) {
// // TODO cache: printStackTrace not needed
// // printStackTrace not needed
// // if we use our own hashtable
// e.printStackTrace();
// }
......
......@@ -8,6 +8,8 @@ package org.h2.util;
import java.sql.SQLException;
import org.h2.message.Trace;
/**
* The cache writer is called by the cache to persist changed data that needs to
* be removed from the cache.
......@@ -28,4 +30,12 @@ public interface CacheWriter {
* log file first, because the log file is 'write ahead'.
*/
void flushLog() throws SQLException;
/**
* Get the trace writer.
*
* @return the trace writer
*/
Trace getTrace();
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论