Hi,
Yes, Script.process(connSource, scriptOut) use the same session, but when i
add more trace in CreateCluster.java, Script.java and Session.Java, my log
file says the opposite.
precision:
- when i use an EMPTY database with version 1.3.168, this problem don't
appear.
- when i use with version 1.2.147, this problem don't appear.
- i want migrate my db 1.2.147 to 1.3.168 in my server ...
(i export sql code from my db 1.2.147 and import to 1.3.168 with Scrit &
Runscript)
- the file in my first post 'DBSConnector.h2.db' is db 1.3.168 with data
from 1.2.147 imported.
For more test case, i recompilate your CreateCluster.java, Script.java and
Session.java class with more trace ... like this:
some lines in CreateCluster.java *Fur_File.Trace();* write in my log file:
// enable the exclusive mode and close other connections,
// so that data can't change while restoring the second database
statSource.execute("SET EXCLUSIVE 2");
*Fur_File.Trace("W0");*
try {
// backup
Script script = new Script();
script.setOut(out);
OutputStream scriptOut = null;
try {
*Fur_File.Trace("W1");*
scriptOut = FileUtils.newOutputStream(scriptFile,
false);
*Fur_File.Trace("W2");*
Script.process(connSource, scriptOut);
*Fur_File.Trace("W3");*
} finally {
*Fur_File.Trace("W4");*
IOUtils.closeSilently(scriptOut);
}
*Fur_File.Trace("W5");*
// delete the target database and then restore
connTarget = DriverManager.getConnection(urlTarget +
";CLUSTER=''", user, password);
*Fur_File.Trace("W6");*
statTarget = connTarget.createStatement();
*Fur_File.Trace("W7");*
statTarget.execute("DROP ALL OBJECTS DELETE FILES");
*Fur_File.Trace("W8");*
connTarget.close();
*Fur_File.Trace("W9");*
RunScript runScript = new RunScript();
*Fur_File.Trace("W10");*
runScript.setOut(out);
*Fur_File.Trace("W11");*
runScript.process(urlTarget, user, password, scriptFile,
null, false);
*Fur_File.Trace("W12");*
connTarget = DriverManager.getConnection(urlTarget, user,
password);
*Fur_File.Trace("W13");*
statTarget = connTarget.createStatement();
*Fur_File.Trace("W14");*
// set the cluster to the serverList on both databases
statSource.executeUpdate("SET CLUSTER '" + serverList +
"'");
*Fur_File.Trace("W15");*
statTarget.executeUpdate("SET CLUSTER '" + serverList +
"'");
*Fur_File.Trace("W16");*
} finally {
* Fur_File.Trace("W17");*
// switch back to the regular mode
statSource.execute("SET EXCLUSIVE FALSE");
*Fur_File.Trace("W18");*
}
} finally {
FileUtils.delete(scriptFile);
JdbcUtils.closeSilently(statSource);
JdbcUtils.closeSilently(statTarget);
JdbcUtils.closeSilently(connSource);
JdbcUtils.closeSilently(connTarget);
}*
*In Script.java:
static void process(Connection conn, OutputStream out) throws SQLException {
Statement stat = null;
try {
*Fur_File.Trace("RRR0");*
stat = conn.createStatement();
*Fur_File.Trace("RRR1");*
PrintWriter writer = new
PrintWriter(IOUtils.getBufferedWriter(out));
*Fur_File.Trace("RRR2");*
ResultSet rs = stat.executeQuery("SCRIPT");
* Fur_File.Trace("RRR3");*
while (rs.next()) {
String s = rs.getString(1);
writer.println(s);
}
*Fur_File.Trace("RRR4");*
writer.flush();
} finally {
*Fur_File.Trace("RRR5");*
JdbcUtils.closeSilently(stat);
*Fur_File.Trace("RRR6");*
}
}
In function waitIfExclusiveModeEnabled (Session.java):
public void waitIfExclusiveModeEnabled() {
while (true) {
Session exclusive = database.getExclusiveSession();
*if (exclusive != null)
Fur_File.Trace("A:"+exclusive.serialId+"__"+exclusive.toString());*
*if (exclusive != null)
Fur_File.Trace("B:"+this.serialId+"__"+this.toString());*
if (exclusive == null || exclusive == this) {
break;
}
if (Thread.holdsLock(exclusive)) {
// if another connection is used within the connection
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
}
}
When i start the cluster (with my db DBSConnector.h2.db in my first post),
here in my log file:
2012-07-17 12:51:31.43+0400: W0
2012-07-17 12:51:31.45+0400: W1
*2012-07-17 12:51:31.46+0400: W2*
2012-07-17 12:51:31.47+0400: RRR0
2012-07-17 12:51:31.48+0400: RRR1
*2012-07-17 12:51:31.49+0400: RRR2*
2012-07-17 12:51:31.57+0400: A:6__#6 (user: SA)
2012-07-17 12:51:31.59+0400: B:6__#6 (user: SA)
2012-07-17 12:51:31.308+0400: *A:6__#6* (user: SA)
2012-07-17 12:51:31.308+0400: *B:5__#5* (user: SA)
2012-07-17 12:51:31.409+0400: A:6__#6 (user: SA)
2012-07-17 12:51:31.410+0400: B:5__#5 (user: SA)
2012-07-17 12:51:31.511+0400: A:6__#6 (user: SA)
2012-07-17 12:51:31.511+0400: B:5__#5 (user: SA)
2012-07-17 12:51:31.612+0400: A:6__#6 (user: SA)
2012-07-17 12:51:31.613+0400: B:5__#5 (user: SA)
2012-07-17 12:51:31.714+0400: A:6__#6 (user: SA)
2012-07-17 12:51:31.715+0400: B:5__#5 (user: SA)
2012-07-17 12:51:31.815+0400: A:6__#6 (user: SA)
2012-07-17 12:51:31.816+0400: B:5__#5 (user: SA)
2012-07-17 12:51:31.917+0400: A:6__#6 (user: SA)
2012-07-17 12:51:31.917+0400: B:5__#5 (user: SA) .............. loop .......
-CreateCluster stop to W2 tag. (Script.process(connSource, scriptOut);)
-Script stop to RRR2 tag. (ResultSet rs = stat.executeQuery("SCRIPT");)
-Detect exclusive session:
2012-07-17 12:51:31.57+0400: A:6__#6 (user: SA)
2012-07-17 12:51:31.59+0400: B:6__#6 (user: SA)
-loop on session non exclusive session:
2012-07-17 12:51:31.308+0400: *A:6__#6* (user: SA)
2012-07-17 12:51:31.308+0400: *B:5__#5* (user: SA)
Script.process is never executed, and my cluster don't start.
What do you thing about ?
It is possible when i export data from 1.2.147, all old informations
session are exported and reused for ?
Thanks,
Jimmitry.
2012/7/16 Thomas Mueller <[email protected]>
> Hi,
>
> But in version 1.3.168, 'Script' use another session ...
>>
>
> Looking at the source code of CreateCluster, the same session is used
> (connSource) in the call Script.process(connSource, scriptOut). Maybe it's
> something else? Could you provide a simple, minimal test case?
>
> Regards,
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.
>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.