提交 8ffac30c authored 作者: Thomas Mueller's avatar Thomas Mueller

When using MULTI_THREADED=TRUE, the exception following exception could be…

When using MULTI_THREADED=TRUE, the exception following exception could be thrown: "object already exists: TABLES"
上级 b2c21f8c
...@@ -163,7 +163,7 @@ public class Database implements DataHandler { ...@@ -163,7 +163,7 @@ public class Database implements DataHandler {
private int cacheSize; private int cacheSize;
private boolean compactFully; private boolean compactFully;
private SourceCompiler compiler; private SourceCompiler compiler;
private boolean metaTablesInitialized; private volatile boolean metaTablesInitialized;
private boolean flushOnEachCommit; private boolean flushOnEachCommit;
private LobStorage lobStorage; private LobStorage lobStorage;
...@@ -589,6 +589,7 @@ public class Database implements DataHandler { ...@@ -589,6 +589,7 @@ public class Database implements DataHandler {
addDefaultSetting(systemSession, SetTypes.CLUSTER, Constants.CLUSTERING_DISABLED, 0); addDefaultSetting(systemSession, SetTypes.CLUSTER, Constants.CLUSTERING_DISABLED, 0);
addDefaultSetting(systemSession, SetTypes.WRITE_DELAY, null, Constants.DEFAULT_WRITE_DELAY); addDefaultSetting(systemSession, SetTypes.WRITE_DELAY, null, Constants.DEFAULT_WRITE_DELAY);
addDefaultSetting(systemSession, SetTypes.CREATE_BUILD, null, Constants.BUILD_ID); addDefaultSetting(systemSession, SetTypes.CREATE_BUILD, null, Constants.BUILD_ID);
getLobStorage().init();
systemSession.commit(true); systemSession.commit(true);
traceSystem.getTrace(Trace.DATABASE).info("opened " + databaseName); traceSystem.getTrace(Trace.DATABASE).info("opened " + databaseName);
afterWriting(); afterWriting();
...@@ -677,11 +678,15 @@ public class Database implements DataHandler { ...@@ -677,11 +678,15 @@ public class Database implements DataHandler {
if (metaTablesInitialized) { if (metaTablesInitialized) {
return; return;
} }
for (int type = 0; type < MetaTable.getMetaTableTypeCount(); type++) { synchronized (infoSchema) {
MetaTable m = new MetaTable(infoSchema, -1 - type, type); if (!metaTablesInitialized) {
infoSchema.add(m); for (int type = 0; type < MetaTable.getMetaTableTypeCount(); type++) {
MetaTable m = new MetaTable(infoSchema, -1 - type, type);
infoSchema.add(m);
}
metaTablesInitialized = true;
}
} }
metaTablesInitialized = true;
} }
private synchronized void addMeta(Session session, DbObject obj) { private synchronized void addMeta(Session session, DbObject obj) {
...@@ -1055,7 +1060,8 @@ public class Database implements DataHandler { ...@@ -1055,7 +1060,8 @@ public class Database implements DataHandler {
// remove all session variables // remove all session variables
if (persistent) { if (persistent) {
try { try {
LobStorage.removeAllForTable(this, LobStorage.TABLE_ID_SESSION_VARIABLE); getLobStorage();
lobStorage.removeAllForTable(LobStorage.TABLE_ID_SESSION_VARIABLE);
} catch (DbException e) { } catch (DbException e) {
traceSystem.getTrace(Trace.DATABASE).error("close", e); traceSystem.getTrace(Trace.DATABASE).error("close", e);
} }
...@@ -2028,6 +2034,9 @@ public class Database implements DataHandler { ...@@ -2028,6 +2034,9 @@ public class Database implements DataHandler {
public Table getFirstUserTable() { public Table getFirstUserTable() {
for (Table table : getAllTablesAndViews(false)) { for (Table table : getAllTablesAndViews(false)) {
if (table.getCreateSQL() != null) { if (table.getCreateSQL() != null) {
if (SysProperties.LOB_IN_DATABASE && table.getSchema() == infoSchema) {
continue;
}
return table; return table;
} }
} }
...@@ -2216,11 +2225,17 @@ public class Database implements DataHandler { ...@@ -2216,11 +2225,17 @@ public class Database implements DataHandler {
public LobStorage getLobStorage() { public LobStorage getLobStorage() {
if (lobStorage == null) { if (lobStorage == null) {
String url = Constants.CONN_URL_INTERNAL; lobStorage = new LobStorage(this);
Connection conn = new JdbcConnection(systemSession, systemUser.getName(), url);
lobStorage = new LobStorage(conn);
} }
return lobStorage; return lobStorage;
} }
public Connection getLobConnection() {
if (SysProperties.LOB_IN_DATABASE) {
String url = Constants.CONN_URL_INTERNAL;
return new JdbcConnection(systemSession, systemUser.getName(), url);
}
return null;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论