You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2006/09/25 11:14:59 UTC
svn commit: r449616 -
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java
Author: kahatlen
Date: Mon Sep 25 02:14:54 2006
New Revision: 449616
URL: http://svn.apache.org/viewvc?view=rev&rev=449616
Log:
DERBY-1326: Network server may abandon sessions when Derby system is
shutdown and this causes intermittent hangs in the client
Added JUnit test case which reliably reproduces the hang.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java?view=diff&rev=449616&r1=449615&r2=449616
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java Mon Sep 25 02:14:54 2006
@@ -54,6 +54,46 @@
}
/**
+ * Test that a shutdown of the engine does not take down the network
+ * server. Before DERBY-1326 was fixed, shutting down the engine would
+ * leave the network server in an inconsistent state which could make
+ * clients hang infinitely.
+ */
+ public void testEngineShutdownDoesNotTakeDownNS() throws Exception {
+ Connection[] conns = new Connection[20];
+
+ // first make sure there are 20 active worker threads on the server
+ for (int i = 0; i < conns.length; i++) {
+ conns[i] = openDefaultConnection();
+ }
+
+ // then close them, leaving 20 free worker threads ready to pick up new
+ // sessions
+ for (int i = 0; i < conns.length; i++) {
+ conns[i].close();
+ }
+
+ // Give the free threads a little time to close their sessions. This is
+ // done to ensure that there are free threads waiting for new sessions,
+ // which makes the DERBY-1326 hang more reliably reproducible.
+ Thread.sleep(500);
+
+ // shut down the engine
+ try {
+ getConnection("", "shutdown=true");
+ fail("shutdown didn't raise exception");
+ } catch (SQLException sqle) {
+ assertSQLState("XJ015", sqle);
+ }
+
+ // see if it is still possible to connect to the server (before
+ // DERBY-1326, this would hang)
+ for (int i = 0; i < 20; i++) {
+ openDefaultConnection().close();
+ }
+ }
+
+ /**
* Test that the NetworkServer shuts down the databases it has booted when
* started from the command line, and that it does not shut down the
* databases it has booted when started from the API.