I committed this change with svn 164994.
Suresh Thalamati wrote:
Thanks Dan. Attached is the new patch which I hope fixes the problem.
-suresh
Daniel John Debrunner wrote:
Suresh Thalamati wrote:
Attached is the new patch with the suggested changes to make
softupgrade correctly with the transaction log
checksum feature in 10.1 Added checkVersion() method to log factory it
self, becuase that is where
the version numbers are read from from the log control file , but did
not export the call it to the
rawstore factory as it is not needed now. (This can be done easlily
when there is a need for upgrade
checks in the other store modules..)
+ boolean checkVersion(int requiredMajorVersion, int requiredMinorVersion)
+ {
+ if(onDiskMajorVersion >= requiredMajorVersion &&
+ onDiskMinorVersion >= requiredMinorVersion)
+ return true;
+ else
+ return false;
+ }
Won't this method return the incorrect result if the on disk is 11.0 (major.minor) and the required version is 10.1? Ie. with this combination the method should return true.
Dan.
------------------------------------------------------------------------
Index: java/engine/org/apache/derby/impl/store/raw/log/LogAccessFile.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/log/LogAccessFile.java (revision 164711)
+++ java/engine/org/apache/derby/impl/store/raw/log/LogAccessFile.java (working copy)
@@ -35,6 +35,7 @@
import org.apache.derby.iapi.services.io.FormatIdOutputStream;
import org.apache.derby.iapi.services.io.ArrayOutputStream;
+import org.apache.derby.iapi.store.raw.RawStoreFactory;
/**
@@ -116,7 +117,7 @@
private long checksumInstant = -1;
private int checksumLength;
private int checksumLogRecordSize; //checksumLength + LOG_RECORD_FIXED_OVERHEAD_SIZE
- private boolean writeChecksum = true; //gets set to false incase of a soft upgrade.
+ private boolean writeChecksum; private ChecksumOperation checksumLogOperation;
private LogRecord checksumLogRecord;
private LogToFile logFactory;
@@ -152,7 +153,14 @@
}
currentBuffer = (LogAccessFileBuffer) freeBuffers.removeFirst();
-
+
+ // Support for Transaction Log Checksum in Derby was added in 10.1
+ // Check to see if the Store have been upgraded to 10.1 or later before
+ // writing the checksum log records. Otherwise recovery will fail
+ // incase user tries to revert back to versions before 10.1 in + // soft upgrade mode. + writeChecksum = logFactory.checkVersion(RawStoreFactory.DERBY_STORE_MAJOR_VERSION_10, + RawStoreFactory.DERBY_STORE_MINOR_VERSION_1);
if(writeChecksum)
{
/**
Index: java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
===================================================================
--- java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (revision 164711)
+++ java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (working copy)
@@ -3885,6 +3885,29 @@
return logArchived;
}
+ /**
+ Check to see if a database has been upgraded to the required
+ level in order to use a store feature.
+ @param requiredMajorVersion required database Engine major version
+ @param requiredMinorVersion required database Engine minor version
+ @return True if the database has been upgraded to the required level, false otherwise.
+ **/
+ boolean checkVersion(int requiredMajorVersion, int requiredMinorVersion) + {
+ if(onDiskMajorVersion > requiredMajorVersion )
+ {
+ return true;
+ }
+ else
+ {
+ if(onDiskMajorVersion == requiredMajorVersion && + onDiskMinorVersion >= requiredMinorVersion)
+ return true;
+ }
+
+ return false;
+ }
+
/*
** Sending information to the user without throwing exception.
** There are times when unusual external or system related things happen in
Index: java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java
===================================================================
--- java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java (revision 164711)
+++ java/engine/org/apache/derby/iapi/store/raw/RawStoreFactory.java (working copy)
@@ -94,7 +94,15 @@
public interface RawStoreFactory extends Corruptable {
+ /** Store engine version numbers indicating the database must be upgraded to + * or created at the current engine level + */
+ /** Derby Store Minor Version (1) **/
+ public static final int DERBY_STORE_MINOR_VERSION_1 = 1;
+ /** Derby 10 Store Major version */
+ public static final int DERBY_STORE_MAJOR_VERSION_10 = 10;
+
/**
Default value for PAGE_SIZE_PARAMETER (4096).
*/
