db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oyste...@apache.org
Subject svn commit: r640631 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/store/raw/log/ engine/org/apache/derby/impl/store/raw/ engine/org/apache/derby/impl/store/raw/data/ engine/org/apache/derby/impl/store/raw/log/ engine/org/apache/derby/loc...
Date Mon, 24 Mar 2008 23:01:29 GMT
Author: oysteing
Date: Mon Mar 24 16:01:24 2008
New Revision: 640631

URL: http://svn.apache.org/viewvc?rev=640631&view=rev
Log:
DERBY-3551: Handle normallyy unlogged operations (create index, import) during replication
Contributed by V Narayanan

1. If unlogged operations are running when replication is started, throw an error.
2. If normally unlogged operations are started when replication is running, turn on logging.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.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/raw/log/ReadOnly.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java?rev=640631&r1=640630&r2=640631&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java Mon
Mar 24 16:01:24 2008
@@ -203,6 +203,17 @@
 	   @return true if the log is being archived.
 	*/
 	public boolean logArchived();
+        
+        /**
+         * Used to determine if the replication master mode has been started,
+         * and the logging for unlogged operations needs to be enabled.
+         *
+         * @return true If the master replication mode is turned on and the 
+         *              unlogged operations need to be logged.
+         *         false If the master replication mode is turned off and the 
+         *               unlogged operations need not be logged.
+         */
+        public boolean inReplicationMasterMode();
 
 	/**
 		Get JBMS properties relavent to the log factory

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java?rev=640631&r1=640630&r2=640631&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java Mon Mar
24 16:01:24 2008
@@ -474,8 +474,12 @@
      * @param replicationMode The type of replication contract.
      * Currently only asynchronous replication is supported, but
      * 1-safe/2-safe/very-safe modes may be added later.
-     * @exception StandardException Standard Derby exception policy,
-     * thrown on error.
+     * @exception StandardException 1) If replication is started on a read-only
+     *                                 database
+     *                              2) If replication is started when unlogged
+     *                                 operations are running
+     *                              3) If an error occurs while trying to boot
+     *                                 the master.
      */
     public void startReplicationMaster(String dbmaster, String host, int port,
                                        String replicationMode)
@@ -484,6 +488,21 @@
         if (isReadOnly()) {
             throw StandardException.newException(
                       SQLState.LOGMODULE_DOES_NOT_SUPPORT_REPLICATION);
+        }
+        
+        RawTransaction t = 
+                xactFactory.findUserTransaction(
+                this,
+                ContextService.getFactory().getCurrentContextManager(), 
+                AccessFactoryGlobals.USER_TRANS_NAME);
+
+        //back up blocking operations are unlogged operations.
+        //Check if any unlogged operations are active and if
+        //yes do not allow replication to start.
+        if (t.isBlockingBackup())
+        {
+            throw StandardException.newException(
+                  SQLState.REPLICATION_UNLOGGED_OPERATIONS_IN_PROGRESS);  
         }
 
         Properties replicationProps = new Properties();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java?rev=640631&r1=640630&r2=640631&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
Mon Mar 24 16:01:24 2008
@@ -669,7 +669,8 @@
 
 				// make sure everything is logged if logArchived is turn on
 				// clear all UNLOGGED flag
-				if (logFactory.logArchived()) {
+				if (logFactory.logArchived() || 
+                                        logFactory.inReplicationMasterMode()) {
 					mode &= ~(ContainerHandle.MODE_UNLOGGED |
 							  ContainerHandle.MODE_CREATE_UNLOGGED);
 

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=640631&r1=640630&r2=640631&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 Mon
Mar 24 16:01:24 2008
@@ -4738,6 +4738,19 @@
 		return null;
 
 	}
+        
+        /**
+         * Used to determine if the replication master mode has been started,
+         * and the logging for unlogged operations needs to be enabled.
+         *
+         * @return true If the master replication mode is turned on and the 
+         *              unlogged operations need to be logged.
+         *         false If the master replication mode is turned off and the 
+         *               unlogged operations need not be logged.
+         */
+        public boolean inReplicationMasterMode() {
+            return inReplicationMasterMode;
+        }
 	
 
 	/*********************************************************************

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java?rev=640631&r1=640630&r2=640631&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java Mon
Mar 24 16:01:24 2008
@@ -463,6 +463,16 @@
         throw StandardException.newException(
                   SQLState.LOGMODULE_DOES_NOT_SUPPORT_REPLICATION);
     }
+    
+    /**
+     * Replication not applicable on readonly databases.
+     *
+     * @return false always since replication is not applicable here.
+     */
+    
+    public boolean inReplicationMasterMode() {
+        return false;
+    }
 
     /** Replication not applicable on readonly databases */
     public void stopReplicationMasterRole() {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=640631&r1=640630&r2=640631&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Mon Mar 24 16:01:24
2008
@@ -4869,6 +4869,11 @@
                 <text>Replication master has already been booted for database '{0}'</text>
                 <arg>dbname</arg>
             </msg>
+            
+            <msg>
+                <name>XRE23</name>
+                <text>Replication master cannot be started since unlogged operations
are in progress, unfreeze to allow unlogged operations to complete and restart replication</text>
+            </msg>
 
             <msg>
                 <name>XRE40</name>

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=640631&r1=640630&r2=640631&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
Mon Mar 24 16:01:24 2008
@@ -1789,6 +1789,7 @@
     String REPLICATION_FAILOVER_SUCCESSFUL                         = "XRE20.D";
     String REPLICATION_FAILOVER_UNSUCCESSFUL                       = "XRE21";
     String REPLICATION_MASTER_ALREADY_BOOTED                       = "XRE22";
+    String REPLICATION_UNLOGGED_OPERATIONS_IN_PROGRESS             = "XRE23";
     String REPLICATION_NOT_IN_SLAVE_MODE                           = "XRE40";
     String SLAVE_OPERATION_DENIED_WHILE_CONNECTED                  = "XRE41";
     String REPLICATION_SLAVE_SHUTDOWN_OK                           = "XRE42";



Mime
View raw message