db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oyste...@apache.org
Subject svn commit: r641318 - in /db/derby/code/branches/10.4/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/d...
Date Wed, 26 Mar 2008 14:07:10 GMT
Author: oysteing
Date: Wed Mar 26 07:07:08 2008
New Revision: 641318

URL: http://svn.apache.org/viewvc?rev=641318&view=rev
Log:
DERBY-3551: Handle normally 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.

Merge to 10.4 branch with command:
svn merge -r640630:640631 https://svn.apache.org/repos/asf/db/derby/code/trunk

Modified:
    db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/RawStore.java
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java
    db/derby/code/branches/10.4/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/branches/10.4/java/shared/org/apache/derby/shared/common/reference/SQLState.java

Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java?rev=641318&r1=641317&r2=641318&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/store/raw/log/LogFactory.java
Wed Mar 26 07:07:08 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/branches/10.4/java/engine/org/apache/derby/impl/store/raw/RawStore.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/RawStore.java?rev=641318&r1=641317&r2=641318&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/RawStore.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/RawStore.java
Wed Mar 26 07:07:08 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/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java?rev=641318&r1=641317&r2=641318&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
Wed Mar 26 07:07:08 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/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java?rev=641318&r1=641317&r2=641318&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
Wed Mar 26 07:07:08 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/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java?rev=641318&r1=641317&r2=641318&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/log/ReadOnly.java
Wed Mar 26 07:07:08 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/branches/10.4/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/loc/messages.xml?rev=641318&r1=641317&r2=641318&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/loc/messages.xml Wed Mar 26 07:07:08
2008
@@ -4851,6 +4851,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/branches/10.4/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=641318&r1=641317&r2=641318&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/shared/org/apache/derby/shared/common/reference/SQLState.java
(original)
+++ db/derby/code/branches/10.4/java/shared/org/apache/derby/shared/common/reference/SQLState.java
Wed Mar 26 07:07:08 2008
@@ -1786,6 +1786,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