提交 819782b5 authored 作者: Thomas Mueller's avatar Thomas Mueller

The CreateCluster tool could not be used if the source database contained a CLOB…

The CreateCluster tool could not be used if the source database contained a CLOB or BLOB. The root cause was that the TCP server did not synchronize on the session, which caused a problem when using the exclusive mode.
上级 2ceb5ec6
......@@ -18,7 +18,10 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Statement.getQueryTimeout(): only the first call to this method will query the database.
<ul><li>The CreateCluster tool could not be used if the source database contained a CLOB or BLOB.
The root cause was that the TCP server did not synchronize on the session, which caused a problem
when using the exclusive mode.
</li><li>Statement.getQueryTimeout(): only the first call to this method will query the database.
If the query timeout was changed in another way than calling setQueryTimeout,
this method will always return the last value. This was changed because Hibernate
calls getQueryTimeout() a lot.
......
......@@ -303,7 +303,10 @@ public class TcpServerThread implements Runnable {
Command command = (Command) cache.getObject(id, false);
setParameters(command);
int old = session.getModificationId();
ResultInterface result = command.executeQuery(maxRows, false);
ResultInterface result;
synchronized (session) {
result = command.executeQuery(maxRows, false);
}
cache.addObject(objectId, result);
int columnCount = result.getVisibleColumnCount();
int state = getState(old);
......@@ -325,7 +328,10 @@ public class TcpServerThread implements Runnable {
Command command = (Command) cache.getObject(id, false);
setParameters(command);
int old = session.getModificationId();
int updateCount = command.executeUpdate();
int updateCount;
synchronized (session) {
updateCount = command.executeUpdate();
}
int status;
if (session.isClosed()) {
status = SessionRemote.STATUS_CLOSED;
......
......@@ -36,6 +36,7 @@ public class TestCluster extends TestBase {
}
public void test() throws Exception {
testClob();
testRecover();
testRollback();
testCase();
......@@ -43,6 +44,43 @@ public class TestCluster extends TestBase {
testStartStopCluster();
}
private void testClob() throws SQLException {
if (config.memory || config.networked || config.cipher != null) {
return;
}
int port1 = 9191, port2 = 9192;
String serverList = "localhost:" + port1 + ",localhost:" + port2;
deleteFiles();
org.h2.Driver.load();
String user = getUser(), password = getPassword();
Connection conn;
Statement stat;
String url1 = "jdbc:h2:tcp://localhost:" + port1 + "/test";
Server n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port1, "-baseDir", getBaseDir() + "/node1").start();
conn = DriverManager.getConnection(url1, user, password);
stat = conn.createStatement();
stat.execute("create table t1(id int, name clob)");
stat.execute("insert into t1 values(1, repeat('Hello', 50))");
conn.close();
String url2 = "jdbc:h2:tcp://localhost:" + port2 + "/test";
Server n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "" + port2 , "-baseDir", getBaseDir() + "/node2").start();
String urlCluster = "jdbc:h2:tcp://" + serverList + "/test";
CreateCluster.main("-urlSource", url1, "-urlTarget", url2, "-user", user, "-password", password, "-serverList",
serverList);
conn = DriverManager.getConnection(urlCluster, user, password);
conn.close();
n1.stop();
n2.stop();
deleteFiles();
}
private void testRecover() throws SQLException {
if (config.memory || config.networked || config.cipher != null) {
return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论