db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oyste...@apache.org
Subject svn commit: r632369 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/db/Database.java impl/db/BasicDatabase.java impl/db/SlaveDatabase.java impl/jdbc/EmbedConnection.java impl/services/replication/master/MasterController.java
Date Fri, 29 Feb 2008 16:06:33 GMT
Author: oysteing
Date: Fri Feb 29 08:06:30 2008
New Revision: 632369

URL: http://svn.apache.org/viewvc?rev=632369&view=rev
Log:
DERBY-3428: Doing a replication failover should shutdown the database and the connection should
no longer be available
The shutdown exception needs to be a StandardException in order to shut down the database
(SQLException does not work)
After failove, unfreeze the database before trying shutdown.
Contributed by V Narayanan



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java?rev=632369&r1=632368&r2=632369&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java Fri Feb 29 08:06:30
2008
@@ -133,13 +133,14 @@
      *
      * @param dbname the replication database that is being failed over.
      *
-     * @exception SQLException   1) If the failover succeeds, an exception is
-     *                              thrown to indicate that the master database
-     *                              was shutdown after a successful failover
-     *                           2) If a failure occurs during network
-     *                              communication with slave.
+     * @exception StandardException 1) If the failover succeeds, an exception
+     *                                 is thrown to indicate that the master
+     *                                 database was shutdown after a successful
+     *                                 failover
+     *                              2) If a failure occurs during network
+     *                                 communication with slave.
      */
-    public void failover(String dbname) throws SQLException;
+    public void failover(String dbname) throws StandardException;
 
     /**
      * Used to indicated whether the database is in the replication

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java?rev=632369&r1=632368&r2=632369&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java Fri Feb 29
08:06:30 2008
@@ -412,12 +412,8 @@
     /**
      * @see org.apache.derby.iapi.db.Database#failover(String)
      */
-    public void failover(String dbname) throws SQLException {
-        try {
-            af.failover(dbname);
-        } catch (StandardException se) {
-            throw PublicAPI.wrapStandardException(se);
-        }
+    public void failover(String dbname) throws StandardException {
+        af.failover(dbname);
     }
 
 	public void freeze() throws SQLException

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=632369&r1=632368&r2=632369&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 Feb 29
08:06:30 2008
@@ -253,30 +253,26 @@
         slaveFac = null;
     }
 
-    public void failover(String dbname) throws SQLException {
-        try {
-            if (inReplicationSlaveMode) {
-                slaveFac.failover();
-                // SlaveFactory#failover will make the 
-                // SlaveDatabaseBootThread complete booting of the store 
-                // modules, and inReplicationSlaveMode will then be set to 
-                // false (see SlaveDatabaseBootThread#run). 
-                // Wait until store is completely booted before returning from 
-                // this method
-                while (inReplicationSlaveMode) {
-                    try {
-                        Thread.sleep(500);
-                    } catch (InterruptedException ie) {
-                    // do nothing
-                    }
+    public void failover(String dbname) throws StandardException {
+        if (inReplicationSlaveMode) {
+            slaveFac.failover();
+            // SlaveFactory#failover will make the
+            // SlaveDatabaseBootThread complete booting of the store
+            // modules, and inReplicationSlaveMode will then be set to
+            // false (see SlaveDatabaseBootThread#run).
+            // Wait until store is completely booted before returning from
+            // this method
+            while (inReplicationSlaveMode) {
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException ie) {
+                // do nothing
                 }
-            } else {
-                // If failover is performed on a master that has been a slave 
-                // earlier
-                super.failover(dbname);
             }
-        } catch (StandardException se) {
-            throw PublicAPI.wrapStandardException(se);
+        } else {
+            // If failover is performed on a master that has been a slave
+            // earlier
+            super.failover(dbname);
         }
     }
     

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=632369&r1=632368&r2=632369&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Fri Feb
29 08:06:30 2008
@@ -852,15 +852,15 @@
      * 
      * @param tr an instance of TransactionResourceImpl Links the connection 
      *           to the database.
-     * @throws java.sql.SQLException 1) Thrown upon a authorization failure 
-     *                           2) If the failover succeeds, an exception is
+     * @throws StandardException 1) If the failover succeeds, an exception is
      *                              thrown to indicate that the master database
      *                              was shutdown after a successful failover
-     *                           3) If a failure occurs during network 
+     *                           2) If a failure occurs during network
      *                              communication with slave.
+     * @throws SQLException      1) Thrown upon a authorization failure.
      */
     private void handleFailoverMaster(TransactionResourceImpl tr)
-        throws SQLException {
+        throws SQLException, StandardException {
 
         // If authorization is turned on, we need to check if this
         // user is database owner.
@@ -906,7 +906,11 @@
         // databases in slave mode since the AuthenticationService has
         // not been booted for the database
 
-        database.failover(getTR().getDBName());
+        try {
+            database.failover(getTR().getDBName());
+        } catch (StandardException se) {
+            throw Util.generateCsSQLException(se);
+        }
     }
 	/**
 	 * Remove any encryption or upgarde properties from the given properties

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java?rev=632369&r1=632368&r2=632369&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/replication/master/MasterController.java
Fri Feb 29 08:06:30 2008
@@ -278,6 +278,13 @@
             //The exception thrown is of Database Severity, this shuts
             //down the master database.
             teardownNetwork();
+
+            //If we require an exception of Database Severity to shutdown the
+            //database to shutdown the database we need to unfreeze first
+            //before throwing the exception. Unless we unfreeze the shutdown
+            //hangs.
+            rawStoreFactory.unfreeze();
+
             throw StandardException.newException
                     (SQLState.REPLICATION_FAILOVER_SUCCESSFUL, dbname);  
         } else {



Mime
View raw message