db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oyste...@apache.org
Subject svn commit: r642191 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/db/ engine/org/apache/derby/impl/store/raw/log/ engine/org/apache/derby/impl/store/replication/master/ engine/org/apache/derby/impl/store/replication/slave/ testing/org/ap...
Date Fri, 28 Mar 2008 10:45:53 GMT
Author: oysteing
Date: Fri Mar 28 03:45:50 2008
New Revision: 642191

URL: http://svn.apache.org/viewvc?rev=642191&view=rev
Log:
DERBY-3447: Shutdown on a database without stopping replication hangs
 - Set replication threads to be daemon threads.
 - Implement ModuleControl#stop for MasterController
 - Adjust test to new behavior
Contributed by V Narayanan

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/master/MasterController.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/slave/SlaveController.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part1_1.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java?rev=642191&r1=642190&r2=642191&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java Fri Mar 28
03:45:50 2008
@@ -126,7 +126,10 @@
         // SlaveDatabaseBootThread is an internal class
         SlaveDatabaseBootThread dbBootThread =
             new SlaveDatabaseBootThread(create, startParams);
-        new Thread(dbBootThread, "derby.slave.boot-" + dbname).start();
+        Thread sdbThread = 
+                new Thread(dbBootThread, "derby.slave.boot-" + dbname);
+        sdbThread.setDaemon(true);
+        sdbThread.start();
 
         // Check that the database was booted successfully, or throw
         // the exception that caused the boot to fail.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java?rev=642191&r1=642190&r2=642191&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java Fri
Mar 28 03:45:50 2008
@@ -5103,7 +5103,9 @@
     public void stopReplicationMasterRole() {
         inReplicationMasterMode = false;
         masterFactory = null;
-        logOut.stopReplicationMasterRole();
+        if(logOut != null) {
+            logOut.stopReplicationMasterRole();
+        }
     }
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/master/MasterController.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/master/MasterController.java?rev=642191&r1=642190&r2=642191&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/master/MasterController.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/master/MasterController.java
Fri Mar 28 03:45:50 2008
@@ -156,11 +156,17 @@
     }
     
     /**
-     * Will stop the replication master service
-     *
-     * Not implemented yet
+     * Will stop the replication master service.
      */
-    public void stop() { }
+    public void stop() { 
+        try {
+            stopMaster();
+        } catch (StandardException se) {
+            repLogger.
+                logError(MessageId.REPLICATION_MASTER_STOPPED, se);
+        }
+       
+    }
 
     ////////////////////////////////////////////////////////////
     // Implementation of methods from interface MasterFactory //
@@ -220,7 +226,8 @@
                                                         transmitter,
                                                         this,
                                                         repLogger);
-                ((Thread)logShipper).start();
+                logShipper.setDaemon(true);
+                logShipper.start();
             }
         } catch (StandardException se) {
             // cleanup everything that may have been started before

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/slave/SlaveController.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/slave/SlaveController.java?rev=642191&r1=642190&r2=642191&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/slave/SlaveController.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/slave/SlaveController.java
Fri Mar 28 03:45:50 2008
@@ -400,6 +400,7 @@
      */
     private void startLogReceiverThread() {
         logReceiverThread = new SlaveLogReceiverThread();
+        logReceiverThread.setDaemon(true);
         logReceiverThread.start();
     }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part1_1.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part1_1.java?rev=642191&r1=642190&r2=642191&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part1_1.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part1_1.java
Fri Mar 28 03:45:50 2008
@@ -199,7 +199,10 @@
         killMaster(masterServerHost, masterServerPort);
         Thread.sleep(5000L); // TEMPORARY to see if slave sees that master is gone!
         
-        // 3.  stopSlave on slave should now be allowed. Observe that the database shall
be shutdown.
+        // 3.  stopSlave on slave should now result in an exception stating that
+        //     the slave database has been shutdown. A master shutdown results
+        //     in a behaviour that is similar to what happens when a stopMaster
+        //     is called.
         db = slaveDatabasePath +FS+ReplicationRun.slaveDbSubPath +FS+ replicatedDb;
         connectionURL = "jdbc:derby:"  
                 + "//" + slaveServerHost + ":" + slaveServerPort + "/"
@@ -218,9 +221,10 @@
             int ec = se.getErrorCode();
             String ss = se.getSQLState();
             String msg = ec + " " + ss + " " + se.getMessage();
-            util.DEBUG("3. Got "+msg + " Expected: " + SQLState.REPLICATION_SLAVE_SHUTDOWN_OK);
+            util.DEBUG("3. Got "+msg + " Expected: " + 
+                    SQLState.REPLICATION_DB_NOT_BOOTED);
             assertTrue(connectionURL + " failed: " + msg, 
-                    SQLState.REPLICATION_SLAVE_SHUTDOWN_OK.equals(ss));
+                    SQLState.REPLICATION_DB_NOT_BOOTED.equals(ss));
             util.DEBUG("3. Failed as expected: " + connectionURL +  " " + msg);
             stopSlaveCorrect = true;
         }



Mime
View raw message