db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satheesh Bandaram <sathe...@Sourcery.Org>
Subject Re: [PATCH] upgrade fix related to checksum support for transaction log to recognize out of order log writes during recovery (Derby-96)
Date Mon, 25 Apr 2005 18:49:12 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
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.<br>
<br>
Satheesh<br>
<br>
Suresh Thalamati wrote:<br>
<blockquote cite="mid426A9E64.5060002@gmail.com" type="cite"><br>
Attached is the&nbsp; new&nbsp; patch&nbsp; with the suggested changes to make
softupgrade correctly with the&nbsp; transaction log
  <br>
checksum feature in 10.1 Added&nbsp; checkVersion() method&nbsp; to log factory
it self,&nbsp; becuase that is where
  <br>
the&nbsp; version numbers are read&nbsp; from&nbsp; from the log control file
, but
did not export the call it to&nbsp; the
  <br>
rawstore factory&nbsp; as it is not needed now.&nbsp; (This can be done easlily
when there is a&nbsp; need for upgrade
  <br>
checks&nbsp; in the other store modules..)
  <br>
  <br>
Thanks
  <br>
-suresht
  <br>
  <br>
  <br>
Mike Matrigali wrote:
  <br>
  <br>
  <blockquote type="cite">Ok, that is the info I needed.&nbsp; Suresh could
you resubmit the change
    <br>
with comments like the one dan has below.&nbsp; And change the check to
    <br>
simply check if the on disk version is is 10.0, no need to check
    <br>
current version.
    <br>
    <br>
It would be nice to have some sort of store facility like the one
    <br>
language has, but the problem for this case is that logging system
    <br>
needs it during boot and there is not much else available until boot
    <br>
is finished.
    <br>
    <br>
    <br>
    <br>
Daniel John Debrunner wrote:
    <br>
    <br>
    <blockquote type="cite">Mike Matrigali wrote:
      <br>
      <br>
      <br>
      <blockquote type="cite">Given that Dan is working on the upgrade
stuff, I think the change below
        <br>
handles the current, and next release fine.&nbsp; More changes can be made
        <br>
as it becomes clear how rest of code is handling soft upgrade.
        <br>
        <br>
Going forward I would like to see a better model for the code below.
For
        <br>
this discussion assume current release is 10.0.x and next 2 releases
        <br>
are 10.1.x and 10.2.x.&nbsp; If derby supports soft upgrade from 10.0.x
        <br>
directly to 10.2.x then the code below will have to change, meaning
        <br>
someone is going to have to remember to change it (maybe a sanity
        <br>
statement could force an error if version is not what is expected?):
        <br>
      </blockquote>
      <br>
      <br>
      <br>
Soft upgrade is expected to work on any previous release, and the code
      <br>
to handle it should work without having to change every release.
      <br>
      <br>
Take a language feature that was added in release X and cannot be used
      <br>
in soft upgrade mode because it writes new information to the system
      <br>
catalogs, that would not be understood by releases earlier than X.
      <br>
      <br>
The language layer handles this by checking that the database (on disk)
      <br>
has been upgraded to at least release X before allowing compilation or
      <br>
execution of the feature, by calling the method
      <br>
DataDictionary.checkVersion().
      <br>
      <br>
E.g. for a routine with a method signature (new in 10.1) this check is
      <br>
made (I'm just about to commit this code).
      <br>
      <br>
// Support for Java signatures in Derby was added in 10.1
      <br>
// Check to see the catalogs have been upgraded to 10.1 before
      <br>
// accepting such a method name for a routine. Otherwise
      <br>
// a routine that works in 10.1 soft upgrade mode would
      <br>
// exist when running 10.0 but not resolve to anything.
      <br>
      <br>
if (this.methodName.indexOf('(') != -1)
      <br>
{
      <br>
&nbsp; getDataDictionary().checkVersion(
      <br>
&nbsp;&nbsp;&nbsp;&nbsp; DataDictionary.DD_VERSION_DERBY_10_1,
      <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"EXTERNAL NAME 'class.method(&lt;signature&gt;)'");
      <br>
      <br>
}
      <br>
      <br>
This style of check will work with any future version so it's a safe
      <br>
approach.
      <br>
      <br>
The store layer needs to have a similar policy.
      <br>
      <br>
Dan.
      <br>
      <br>
      <br>
      <br>
    </blockquote>
    <br>
    <br>
  </blockquote>
  <br>
  <pre wrap="">
<hr size="4" width="90%">
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 &gt;= requiredMajorVersion &amp;&amp;
+		   onDiskMinorVersion &gt;= 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).
 	*/
  </pre>
</blockquote>
</body>
</html>


Mime
View raw message