I wish eventually we could consolidate all the version checking logic
in one place, common to the whole engine. Current Derby client patch
has similar logic, in package org.apache.derby.client.am.ProductLevel,
though this is also used for other purpose.
Satheesh
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..)
Thanks
-suresht
Mike Matrigali wrote:
Ok, that is the info I needed. Suresh could
you resubmit the change
with comments like the one dan has below. And change the check to
simply check if the on disk version is is 10.0, no need to check
current version.
It would be nice to have some sort of store facility like the one
language has, but the problem for this case is that logging system
needs it during boot and there is not much else available until boot
is finished.
Daniel John Debrunner wrote:
Mike Matrigali wrote:
Given that Dan is working on the upgrade
stuff, I think the change below
handles the current, and next release fine. More changes can be made
as it becomes clear how rest of code is handling soft upgrade.
Going forward I would like to see a better model for the code below.
For
this discussion assume current release is 10.0.x and next 2 releases
are 10.1.x and 10.2.x. If derby supports soft upgrade from 10.0.x
directly to 10.2.x then the code below will have to change, meaning
someone is going to have to remember to change it (maybe a sanity
statement could force an error if version is not what is expected?):
Soft upgrade is expected to work on any previous release, and the code
to handle it should work without having to change every release.
Take a language feature that was added in release X and cannot be used
in soft upgrade mode because it writes new information to the system
catalogs, that would not be understood by releases earlier than X.
The language layer handles this by checking that the database (on disk)
has been upgraded to at least release X before allowing compilation or
execution of the feature, by calling the method
DataDictionary.checkVersion().
E.g. for a routine with a method signature (new in 10.1) this check is
made (I'm just about to commit this code).
// Support for Java signatures in Derby was added in 10.1
// Check to see the catalogs have been upgraded to 10.1 before
// accepting such a method name for a routine. Otherwise
// a routine that works in 10.1 soft upgrade mode would
// exist when running 10.0 but not resolve to anything.
if (this.methodName.indexOf('(') != -1)
{
getDataDictionary().checkVersion(
DataDictionary.DD_VERSION_DERBY_10_1,
"EXTERNAL NAME 'class.method(<signature>)'");
}
This style of check will work with any future version so it's a safe
approach.
The store layer needs to have a similar policy.
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 164300)
+++ 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 164300)
+++ java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (working copy)
@@ -3885,6 +3885,22 @@
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 &&
+ onDiskMinorVersion >= requiredMinorVersion)
+ return true;
+ else
+ 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 164300)
+++ 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).
*/
|