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

Auto-reconnect: if another connection uses the database in exclusive mode then…

Auto-reconnect: if another connection uses the database in exclusive mode then this connection will try to re-connect until the exclusive mode ends.
上级 e5ba217f
...@@ -29,6 +29,9 @@ Change Log ...@@ -29,6 +29,9 @@ Change Log
</li><li>Cluster: after a cluster node failed, the second cluster node can now be re-created </li><li>Cluster: after a cluster node failed, the second cluster node can now be re-created
and started without having to stop the first cluster node, and without having to stop and started without having to stop the first cluster node, and without having to stop
running applications. To do that, append ;AUTO_RECONNECT=TRUE to the database URL. running applications. To do that, append ;AUTO_RECONNECT=TRUE to the database URL.
</li><li>Auto-reconnect: if another connection uses the database in exclusive mode
then this connection will try to re-connect until the exclusive mode ends.
This is important when using the cluster mode.
</li><li>SET EXCLUSIVE now supports 0 (disable), 1 (enable), and 2 (enable and close all other connections). </li><li>SET EXCLUSIVE now supports 0 (disable), 1 (enable), and 2 (enable and close all other connections).
</li><li>Installing the H2 as a service should now work on Windows 7. </li><li>Installing the H2 as a service should now work on Windows 7.
The batch files now explicitly set the directory using pushd "%~dp0". The batch files now explicitly set the directory using pushd "%~dp0".
......
...@@ -1114,6 +1114,10 @@ variables and local temporary tables definitions (excluding data) are re-created ...@@ -1114,6 +1114,10 @@ variables and local temporary tables definitions (excluding data) are re-created
The contents of the system table <code>INFORMATION_SCHEMA.SESSION_STATE</code> The contents of the system table <code>INFORMATION_SCHEMA.SESSION_STATE</code>
contains all client side state that is re-created. contains all client side state that is re-created.
</p> </p>
<p>
If another connection uses the database in exclusive mode (enabled using <code>SET EXCLUSIVE 1</code>
or <code>SET EXCLUSIVE 2</code>), then this connection will try to re-connect until the exclusive mode ends.
</p>
<h2 id="auto_mixed_mode">Automatic Mixed Mode</h2> <h2 id="auto_mixed_mode">Automatic Mixed Mode</h2>
<p> <p>
......
...@@ -427,7 +427,22 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D ...@@ -427,7 +427,22 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
return false; return false;
} }
lastReconnect++; lastReconnect++;
embedded = connectEmbeddedOrServer(false); while (true) {
try {
embedded = connectEmbeddedOrServer(false);
break;
} catch (DbException e) {
if (e.getErrorCode() != ErrorCode.DATABASE_IS_IN_EXCLUSIVE_MODE) {
throw e;
}
// exclusive mode: re-try endlessly
try {
Thread.sleep(500);
} catch (Exception e2) {
// ignore
}
}
}
if (embedded == this) { if (embedded == this) {
// connected to a server somewhere else // connected to a server somewhere else
embedded = null; embedded = null;
......
...@@ -301,15 +301,6 @@ java org.h2.test.TestAll timer ...@@ -301,15 +301,6 @@ java org.h2.test.TestAll timer
test with small freeList pages, page size 64 test with small freeList pages, page size 64
test services on Windows
exclusive + auto_restart = retry
data store: automatically fast when moving data from two repositories that
share the same data store, using special input stream classes
h2-schema function
power failure test power failure test
power failure test: MULTI_THREADED=TRUE power failure test: MULTI_THREADED=TRUE
power failure test: larger binaries and additional index. power failure test: larger binaries and additional index.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论